Back to top

Autore Topic: Modulo Link Random per J! 1.0.x - Non trovo l'errore che me lo blocca!  (Letto 1416 volte)

Offline stecciu

  • Nuovo arrivato
  • *
  • Post: 33
    • Mostra profilo
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 :
Codice: [Seleziona]
[...]
<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 :
Codice: [Seleziona]
[...]


# 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

Offline ilovephp

  • Esploratore
  • **
  • Post: 175
  • Sesso: Maschio
    • Mostra profilo
$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
Consulenze per la realizzazione e personalizzazione di siti web dinamici. Inoltre, sul sito
http://www.soluzioniperilweb.it
sono disponibili manuali di sviluppo joomla.

Offline stecciu

  • Nuovo arrivato
  • *
  • Post: 33
    • Mostra profilo
.... 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


 



Web Design Bolzano Kreatif