Ciao a tutti sto sviluppando un modulo per Joomla! 1.0.x dove vengono messi dei link random dalla tabella del componente WEBLINKS . Qusto modulo è semplicissimo ma non riesco a trovare un errore (ancora più banale..).
Vi metto qui sotto il codice del modulo:
da mod_random_link.xml :
[...]
<params>
<param name="moduleclass_sfx" type="text" default="" label="Module Class Suffix" description="A suffix to be applied to the css class of the module (table.moduletable), this allows individual module styling" />
<param name="items" type="text" default="5" label="N° link to show" description="The number of link to show in the module" />
</params>
<files>
<filename module="mod_random_link">mod_random_link.php</filename>
</files>
[...]
da mod_random_link.php :
[...]
# Module Parameter Settings
$moduleclass_sfx = $params->get( 'moduleclass_sfx' );
$items = $params->get( 'items', 5 );
### DONT EDIT BELOW THIS LINE #################################################
# Don't allow direct acces to the file
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
$content = "";
# Set up database query
$query = "SELECT id, title, url, published, approved
FROM #__weblinks
WHERE "
. "\n ("
. " published=1 AND approved=1 ORDER BY RAND() LIMIT $items";
# Query the database
$database->setQuery( $query );
$rows = $database->loadObjectList();
# Put the output on screen
$content .="<table width=\"100%\" class=\"moduletable\"".$moduleclass_sfx."\">";
$i=0;
foreach($rows as $row) {
$content .= "<tr><td width=\"10px\" valign=\"middle\" style=\"text-align:center\"><a href=".$row->url."><img src=\"images/M_images/arrow.png\" /></a></td>";
$content .= "<td style=\"text-align:left\"><a href=".$row->url.">".$row->title."</a></td>";
$content .= "</tr>";
$i++;
}
$content .="</table>";
[...]
Qualcuno sa anche se già esiste un modulo simile che non riesco a trovarlo? Almeno evito di trovare l'errore e di farlo da solo..
Grazie a tutti!
p.s.: l'errore è il seguente:
Warning: Invalid argument supplied for foreach() in /web/htdocs/.../home/modules/mod_random_link.php on line 39
la linea è quella del foreach