Help is very much appreciated!!

Haven’t been here in a while but I have stumped myself at the moment or maybe I’ve looked at it too much LOL

This is what I have and it does work but gives me errors on my page… This is my helper.php:

[php]function truncText($text, $chars)
{
if (strlen($text) <= $chars) return $text;
$new = wordwrap($text, $chars, “|”);
$newtext=explode("|",$new);
return $newtext[0];
}

function getRSS( $params )
{
	$doc = new DOMDocument();
	$doc->load($params->get( 'feed', 'http://googleblog.blogspot.com/atom.xml' ));
	$arrFeeds = array();
	foreach ($doc->getElementsByTagName('item') as $node) {
		if ($i >= $params->get('numitems',5)){ break; }
		$arrFeeds[$i]->title = $node->getElementsByTagName('title')->item(0)->nodeValue;
		$arrFeeds[$i]->desc = self::truncText($node->getElementsByTagName('description')->item(0)->nodeValue, $params->get( 'desclen', 120));
		$arrFeeds[$i]->link = $node->getElementsByTagName('link')->item(0)->nodeValue;
		$arrFeeds[$i]->pubDate = $node->getElementsByTagName('pubDate')->item(0)->nodeValue;

		$i++;
	}

	return $arrFeeds;
}

}[/php]

The error I am getting is this:

Notice: Undefined variable: i in helper.php on line 33

Notice: Undefined variable: i in helper.php on line 34

Warning: Creating default object from empty value in helper.php on line 34

Notice: Undefined variable: i in helper.php on line 35

Notice: Undefined variable: i in helper.php on line 36

Notice: Undefined variable: i in helper.php on line 37

Notice: Undefined variable: i in helper.php on line 39

Warning: Creating default object from empty value in helper.php on line 34

Warning: Creating default object from empty value in helper.php on line 34

Warning: Creating default object from empty value in helper.php on line 34

Warning: Creating default object from empty value in helper.php on line 34

So there you have it… not sure how to fix it… Any help is appreciated to show me the errors of my ways…

In the code you posted, $i is not set anywhere.

Yes I know that but I have it working but with errors so I have to set the i$ but at this point I’ve stared at it for so long I’m just not seeing it… :o

Try

[php]$i=0;
$arrFeeds = array();[/php]

Changed it to this:

[php]$doc = new DOMDocument();
$doc->load($params->get( ‘feed’, ‘http://googleblog.blogspot.com/atom.xml’ ));
$i=0;
$arrFeeds = array();
foreach ($doc->getElementsByTagName(‘item’) as $node) {

		if ($i >= $params->get('numitems',5)){ break; }
		$arrFeeds[$i]->title = $node->getElementsByTagName('title')->item(0)->nodeValue;
		$arrFeeds[$i]->desc = self::truncText($node->getElementsByTagName('description')->item(0)->nodeValue, $params->get( 'desclen', 120));
		$arrFeeds[$i]->link = $node->getElementsByTagName('link')->item(0)->nodeValue;
		$arrFeeds[$i]->pubDate = $node->getElementsByTagName('pubDate')->item(0)->nodeValue;

		$i++;[/php]

Just getting one error now…:

Creating default object from empty value in helper.php on line 36

line 36 is : $arrFeeds[$i]->title = $node->getElementsByTagName(‘title’)->item(0)->nodeValue;

This is the file that actually does the output…

[code]


<?php echo $params->get('pretext'); ?>

<?php foreach ($list as $item) : ?>
		<a href="<?php echo $item->link; ?>" target="_blank">
		<?php
		echo ($item->title);
		if ($params->get( 'displayType') == 'titledesc')
		{
			echo (' : ' . $item->desc . '...');
		}
		echo "&nbsp;&nbsp;&nbsp;&nbsp;" . $params->get('itemsep', '|') . "&nbsp;&nbsp;&nbsp;&nbsp;";
		?>
		</a>
<?php endforeach; ?>
	</marquee>
</div>
[/code]

Well it’s not a fix but it is LOL it worked…

[php]error_reporting(E_ERROR | E_PARSE);[/php]

I did keep the

[php]$1=0;[/php]

But used the E_PARSE to stop reporting … :wink:

Nooooooooo! Not allowed. Fix it, don’t hide it.

I got rid of it … now I just have a mess…

Strict Standards: Non-static method modScrollerHelper::getRSS() should not be called statically in php on line 20 Warning: DOMDocument::load(): http:// wrapper is disabled in the server configuration by allow_url_fopen=0 on line 32 Warning: DOMDocument::load(http://cowboysblog.dallasnews.com/index.xml): failed to open stream: no suitable wrapper could be found in helper.php on line 32 Warning: DOMDocument::load(): I/O warning : failed to load external entity "http://cowboysblog.dallasnews.com/index.xml" in helper.php on line 32

NOW I got a mess LOL I did take the error parse out … but now I have no feed but at least I can see why LOL

Suggestions on this one?

Where did you get this code and what exactly are you wanting to do? (Besides make this code work)

It’s an old module for joomla to get an RSS feed and display it as a ‘ticker’…

I’m trying to adapt it to work with Joomla 3.3… it was written for 2.5 but they are different. That same code without editing works in 2.5 but not in 3.3.

Sponsor our Newsletter | Privacy Policy | Terms of Service