>>  Site Map >>  Forums >>  Blocks

Forum module - topics in forum:



Blocks - Having problems with a block? Code doesn't work, get help here.



Attempting to Make A Block

I figure the best way to learn this stuff (besides bugging you Embarassed ) is to just do it....And I couldn't find one to do this...

I am trying to create a block, which will scroll rss feeds from multiple sources.....4 to be exact

I took a block of similiar nature (no copyrights were on it) and redid it....this block was pulling all the sites feeds it had....I want it to pull feeds from different sites....

(And I don't know why the one section (scroller) is in German....I think whoever did the block also did what I am doing.....)

It kind of works...it is scrolling feeds....but there are also errors showing....2 mainly....(4 altogether)

Warning: implode(): Bad arguments.
and
Warning: file(http://www.clevelandsportszone.com/rocks/rss-blog.php): failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in

Here's what I did....blocks-Multiple_RSS.php

Code: :
<?php


if (eregi("block-Multiple_RSS.php", $PHP_SELF)) {
    Header("Location: index.php");
    die();
}

$rdfsource1 ="http://www.clevelandsportszone.com/rocks/backend.php";
$rdfsource2= "http://tribesportsclub.blogdrive.com/index.xml";
$rdfsource3= "http://www.clevelandsportszone.com/rocks/rss-blog.php";
$rdfsource4= "http://www.clevelandsportszone.com/rocks/rss-forums.php";
 
   
$rdfname1  = "CSZ News";   
$rdfname2  = "Tribe Sports";   
$rdfname3  = "The CSZ Blogger";
$rdfname4  = "CSZ Forum Posts";


$homelink1 = "http://www.clevelandsportszone.com/rocks/backend.php"; 
$homelink2 = "http://tribesportsclub.blogdrive.com/index.xml";
$homelink3 = "http://www.clevelandsportszone.com/rocks/";
$homelink4 = "http://www.clevelandsportszone.com/rocks/modules.php?name=Forums";


$scrollen  = 1;    #1 ein, 0 aus   // scrolling 1=on 0 =off
$richtung  = "up"; # Richtug/Direction up down left order right  wenn/if $scrollen=1
$speed     = 1;    # scrollgeschwindigkeit wenn / scrollig speed if $scrollen=1
$warte     = 20;   # scrollverzögerung wenn / scroll delay if $scrollen=1

If (($richtung=="left") or ($richtung=="right")){
   $hoehe=10;
   $waagerecht= 1;}
else{
   $hoehe=190;
   $waagerecht= 0;}
   
If ($waagerecht==0)
        {
        If ($scrollen==1)
        {
      
      

      
      
      
$content = " <A name= \"scrollingCode\"></A>";


      
      
$content .= "<MARQUEE behavior= \"scroll\" align= \"left\" cellpadding=\"5\" direction= \"".$richtung."\" height=\"".$hoehe."\" scrollamount= \"".$speed."\" scrolldelay= \"".$warte."\" onmouseover='this.stop()' onmouseout='this.start()'>";
      }
        else
        {
        $content="";
        }
        $content .= "<center>* * *<br><b>".$rdfname1." </b></center><br>\n\n";
        $data = implode ("", file ($rdfsource1));
      preg_match_all("|<item>(.*)</item>|Uism",$data, $items, PREG_PATTERN_ORDER);
      If (count($items[1])==0) {
      preg_match_all("|<item .*>(.*)</item>|Uism",$data, $items, PREG_PATTERN_ORDER);}
      for ($i=0;$i<count($items[1]);$i++)
      {
        preg_match_all("|<title>(.*)</title>(.*)<link>(.*)</link>|Uism",$items[1][$i], $regs, PREG_PATTERN_ORDER);
        $content .="<a href=\"".$regs[3][0]."\" target='_blank'>".$regs[1][0]."</a><br><br>\n\n";
      }
      $content .="<a href=\"".$homelink1."\" target='_blank' >more...</a><br><br>\n\n";
      
    If (!$rdfsource2==""){
        $content .= "<center>* * *<br><b>".$rdfname2." </b></center><br>\n\n";
        $data = implode ("", file ($rdfsource2));
      preg_match_all("|<item>(.*)</item>|Uism",$data, $items, PREG_PATTERN_ORDER);
      If (count($items[1])==0) {
      preg_match_all("|<item .*>(.*)</item>|Uism",$data, $items, PREG_PATTERN_ORDER);}
      for ($i=0;$i<count($items[1]);$i++)
      {
        preg_match_all("|<title>(.*)</title>(.*)<link>(.*)</link>|Uism",$items[1][$i], $regs, PREG_PATTERN_ORDER);
        $content .="<a href=\"".$regs[3][0]."\" target='_blank'>".$regs[1][0]."</a><br><br>\n\n";
      }
      $content .="<a href=\"".$homelink2."\" target='_blank' >more...</a><br><br>\n\n";
      }
    If (!$rdfsource3==""){
        $content .= "<center>* * *<br><b>".$rdfname3."                                     </b></center><br>\n\n";
        $data = implode ("", file ($rdfsource3));
      preg_match_all("|<item>(.*)</item>|Uism",$data, $items, PREG_PATTERN_ORDER);
      If (count($items[1])==0) {
      preg_match_all("|<item .*>(.*)</item>|Uism",$data, $items, PREG_PATTERN_ORDER);}
      for ($i=0;$i<count($items[1]);$i++)
      {
        preg_match_all("|<title>(.*)</title>(.*)<link>(.*)</link>|Uism",$items[1][$i], $regs, PREG_PATTERN_ORDER);
        $content .="<a href=\"".$regs[3][0]."\" target='_blank'>".$regs[1][0]."</a><br><br>\n\n";
      }
      $content .="<a href=\"".$homelink3."\" target='_blank' >more...</a><br><br>\n\n";
      }
    If (!$rdfsource4==""){
        $content .= "<center>* * *<br><b>".$rdfname4."                                          </b></center><br>\n\n";
        $data = implode ("", file ($rdfsource4));
      preg_match_all("|<item>(.*)</item>|Uism",$data, $items, PREG_PATTERN_ORDER);
      If (count($items[1])==0) {
      preg_match_all("|<item .*>(.*)</item>|Uism",$data, $items, PREG_PATTERN_ORDER);}
      for ($i=0;$i<count($items[1]);$i++)
      {
        preg_match_all("|<title>(.*)</title>(.*)<link>(.*)</link>|Uism",$items[1][$i], $regs, PREG_PATTERN_ORDER);
        $content .="<a href=\"".$regs[3][0]."\" target='_blank'>".$regs[1][0]."</a><br><br>\n\n";
      }
      $content .="<a href=\"".$homelink4."\" target='_blank' >more...</a><br><br>\n\n";
      }
       }
   else
      {
        if ($scrollen==1)
      {
         $content = " <A name= \"scrollingCode\"></A><MARQUEE behavior= \"scroll\" align= \"center\" direction= \"".$richtung."\" height=\"".$hoehe."\" scrollamount= \"".$speed."\" scrolldelay= \"".$warte."\" onmouseover='this.stop()' onmouseout='this.start()'>";
      }
      else
      {
         $content = "";
      }
      $content .="--------&nbsp;<b>".$rdfname1."</b> &nbsp;----------&nbsp;&nbsp;**&nbsp;&nbsp;";
      
      $data = implode ("", file ($rdfsource));
      preg_match_all("|<item>(.*)</item>|Uism",$data, $items, PREG_PATTERN_ORDER);
      If (count($items[1])==0) {
      preg_match_all("|<item .*>(.*)</item>|Uism",$data, $items, PREG_PATTERN_ORDER);}
      for ($i=0;$i<count($items[1]);$i++)
      {
        preg_match_all("|<title>(.*)</title>(.*)<link>(.*)</link>|Uism",$items[1][$i], $regs, PREG_PATTERN_ORDER);
        $content .="<a href=\"".$regs[3][0]."\" target='_blank'>".$regs[1][0]."</a>&nbsp;&nbsp;**&nbsp;&nbsp;";
      }
      $content .="<a href=\"".$homelink1."\" target='_blank' >more...</a>&nbsp;&nbsp;**&nbsp;&nbsp;";
    if (!$rdfsource2=="")
    {
        $content .="--------&nbsp;<b>".$rdfname2."</b> &nbsp;----------&nbsp;&nbsp;**&nbsp;&nbsp;";
      
      $data = implode ("", file ($rdfsource2));
      preg_match_all("|<item>(.*)</item>|Uism",$data, $items, PREG_PATTERN_ORDER);
      If (count($items[1])==0) {
      preg_match_all("|<item .*>(.*)</item>|Uism",$data, $items, PREG_PATTERN_ORDER);}
      for ($i=0;$i<count($items[1]);$i++)
      {
        preg_match_all("|<title>(.*)</title>(.*)<link>(.*)</link>|Uism",$items[1][$i], $regs, PREG_PATTERN_ORDER);
        $content .="<a href=\"".$regs[3][0]."\" target='_blank'>".$regs[1][0]."</a>&nbsp;&nbsp;**&nbsp;&nbsp;";
      }
      $content .="<a href=\"".$homelink2."\" target='_blank' >more...</a>&nbsp;&nbsp;**&nbsp;&nbsp;";
   }
    if (!$rdfsource3=="")
    {
        $content .="--------&nbsp;<b>".$rdfname3."</b> &nbsp;----------&nbsp;&nbsp;**&nbsp;&nbsp;";
      
      $data = implode ("", file ($rdfsource3));
      preg_match_all("|<item>(.*)</item>|Uism",$data, $items, PREG_PATTERN_ORDER);
      If (count($items[1])==0) {
      preg_match_all("|<item .*>(.*)</item>|Uism",$data, $items, PREG_PATTERN_ORDER);}
      for ($i=0;$i<count($items[1]);$i++)
      {
        preg_match_all("|<title>(.*)</title>(.*)<link>(.*)</link>|Uism",$items[1][$i], $regs, PREG_PATTERN_ORDER);
        $content .="<a href=\"".$regs[3][0]."\" target='_blank'>".$regs[1][0]."</a>&nbsp;&nbsp;**&nbsp;&nbsp;";
      }
      $content .="<a href=\"".$homelink3."\" target='_blank' >more...</a>&nbsp;&nbsp;**&nbsp;&nbsp;";
   }
     if (!$rdfsource4=="")
    {
        $content .="--------&nbsp;<b>".$rdfname4."</b> &nbsp;----------&nbsp;&nbsp;**&nbsp;&nbsp;";
      
      $data = implode ("", file ($rdfsource4));
      preg_match_all("|<item>(.*)</item>|Uism",$data, $items, PREG_PATTERN_ORDER);
      If (count($items[1])==0) {
      preg_match_all("|<item .*>(.*)</item>|Uism",$data, $items, PREG_PATTERN_ORDER);}
      for ($i=0;$i<count($items[1]);$i++)
      {
        preg_match_all("|<title>(.*)</title>(.*)<link>(.*)</link>|Uism",$items[1][$i], $regs, PREG_PATTERN_ORDER);
        $content .="<a href=\"".$regs[3][0]."\" target='_blank'>".$regs[1][0]."</a>&nbsp;&nbsp;**&nbsp;&nbsp;";
      }
      $content .="<a href=\"".$homelink4."\" target='_blank' >    more...</a>&nbsp;&nbsp;**&nbsp;&nbsp;";
   }
}


?>


I'm not sure if there's a way to set how many articles for each link...or how long of a description for each article...I think there is for how many articles to display...

Once I know how I broke it, I will try to add comments to make it more user friendly........

And if it does work, please feel free to call it yours....

I am certain the errors I am getting are sticking out like sore thumbs....






Your errors are probably being caused by the fact that these 2 files don't exist on your web server
Code: :
$rdfsource3= "http://www.clevelandsportszone.com/rocks/rss-blog.php";
$rdfsource4= "http://www.clevelandsportszone.com/rocks/rss-forums.php";

Can't pull information from something that doesn't exist.




Thanks!

I'll be damn SevenO! That was all that was wrong....

I feel pretty stupid.....But it's the stupid things that hang you up when your teaching yourself from scratch.....

I also had the links to the READ MORE wrong......

So, is there a setting for the amount of articles for each feed ? I thought there was, but now I don't think so....?

And no setting for how many words to display for each article being fed....?

If no, I'll clean it up some and put it out there for anyone to use.....it is working sweeet.


/************************************************************************/
/* PHP-NUKE: Multiple RSS Feed block */
/* =========================== */
/* This block will feed and scroll 4 seperate rss feeds. To use, change the rdfsource to the sites rss feed page. Place the sites name in the corresponding rdfname section, and finally place the sites URL in the corresponding homelink section. */
/* */
/*Modified by THE CSZ with Help by SevenONine at NukeCode.com. */
/* */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License. */
/************************************************************************/


Will that work for directions?




Attention! You are currently viewing sitemap page!
We strongly suggest to look at original content

Search from web

Valid HTML 4.01 Valid CSS