Joomla.it Forum

Non solo Joomla... => Sviluppo => : stecciu 08 Mar 2008, 11:34:31

: Modulo Link Random per J! 1.0.x - Non trovo l'errore che me lo blocca!
: stecciu 08 Mar 2008, 11:34:31
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
: Re: Modulo Link Random per J! 1.0.x - Non trovo l'errore che me lo blocca!
: ilovephp 10 Mar 2008, 11:49:08
$query = "SELECT id, title, url, published, approved
            FROM #__weblinks
            WHERE "
                . "\n ("
            . " published=1 AND approved=1 ORDER BY RAND() LIMIT $items";

 ??? ??? ???

forse cè un parentesi in +

SELECT id, title, url, published, approved
FROM #__weblinks
WHERE published =1
AND approved =1
ORDER BY RAND( )
LIMIT 0 , 30
: Re: Modulo Link Random per J! 1.0.x - Non trovo l'errore che me lo blocca!
: stecciu 10 Mar 2008, 19:11:09
.... eh eh....  ::)
lo sapevo che era una banalità..
ho caricato il modulo nella sezione download in attesa di conferma!
ciao e grazie per l'aiuto..
 ;D