Question

We have developed a shoutbox which works fine of Joomla 1.5 and 2.5. I make it Joomla 3.0 compatible by changing the version in the XML and a few other bits n bobs.

When I try and load the page that the shoutbox module is assigned to, I get the following error messages:

Notice: Trying to get property of non-object in C:\wamp\www\XXX\libraries\legacy\module\helper.php on line 150

Notice: Undefined property: stdClass::$content in C:\wamp\www\XXX\templates\system\html\modules.php on line 17

I narrowed it down to a single line that is causing the problem, which is:

$rows = $db->loadObjectList();

This line comes from the following function to retrieve the shouts:

function getShouts($number, $timezone, $message) {
    global $mainframe;
    $shouts = array();
    $db =& JFactory::getDBO();
    $query = 'SELECT * FROM #__shoutbox ORDER BY id DESC';
    $db->setQuery($query , 0 , $number);
    $rows = $db->loadObjectList();
    $i=0;
    $timezone=$timezone*60*60;
    foreach ( $rows as $row ) {
        $shouts[$i]->id = $row->id;
        $shouts[$i]->name = $row->name;
        $adjustedtime = strtotime($row->when) + $timezone;
        $shouts[$i]->when = date( 'Y-m-d H:i:s', $adjustedtime);
        $shouts[$i]->ip = $row->ip;
        $shouts[$i]->msg = $row->msg;
        $i++;
    }
    return $shouts;
}

I honestly have no idea why I'm getting these 2 errors as they module works perfectly in previous Joomla versions. I've tried using different methods to get the shouts but nothing worked.

Does anyone have any ideas as to why this might be happening and have a solution?

Was it helpful?

Solution

I don't know how it worked for you in 2.5 but you need http://www.theartofjoomla.com/home/9-developer/135-database-upgrades-in-joomla-16.html $query = $db->getQuery(true);

and also you shouldn't use the & here $db =& JFactory::getDBO(); since objects are always passed by reference.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top