problem with $params->get - Joomla! Forum - community, help and support
hi,
i'm developing plugin, have problem $params->get
in plugin admin section have parameter show column (names of categories) of db table.
if choose 1 of them, in frontend should see news of category.
but in frontend can't retrieve name of choosen category..the $params->get('name') istruction seems not work.
i post code...
mod_ultimeofferte.xml
-----------
mod_ultimeofferte.php
--------------------------------
helper.php
--------------------------
tmpl/default.php
---------------------------
there others 2 file.. index.html , /tmpl/index.html
the code
i'm developing plugin, have problem $params->get
in plugin admin section have parameter show column (names of categories) of db table.
if choose 1 of them, in frontend should see news of category.
but in frontend can't retrieve name of choosen category..the $params->get('name') istruction seems not work.
i post code...
mod_ultimeofferte.xml
code: select all
<?xml version="1.0" encoding="utf-8"?>
<install type="module" version="1.5.0">
<name>mostra offerte</name>
<author>valerio</author>
<version>1.5.0</version>
<description>mostra le ultime offerte</description>
<files>
<filename module="mod_ultimeofferte">mod_ultimeofferte.php</filename>
<filename>index.html</filename>
<filename>helper.php</filename>
<filename>tmpl/default.php</filename>
<filename>tmpl/index.html</filename>
</files>
<params>
<param name="name" type="sql" default="non ci sono categorie" label="seleziona una categoria" query="select name #__sobi2_categories"/>
</params>
</install>
-----------
mod_ultimeofferte.php
code: select all
<?php
// no direct access
defined( '_jexec' ) or die( 'restricted access' );
// include syndicate functions once
require_once( dirname(__file__).ds.'helper.php' );
$offerte = modultimeoffertehelper::getofferte($params);
require( jmodulehelper::getlayoutpath('mod_ultimeofferte'));
?>
--------------------------------
helper.php
code: select all
<?php
class modultimeoffertehelper
{
function getofferte( &$params )
{
$name = $params->get('name');
$db =& jfactory::getdbo();
$query = "select `catid`,`titolo`,`testo`,`scheda` `#__sobi2_cat_items_relations` join `#__sobi2_plugin_notizie` on `scheda` = `itemid` `pubblicato` = 1 order `scheda` desc, `inizio`";
$db->setquery($query);
$rows = $db->loadobjectlist();
if ($db->geterrornum()) {
echo $db->stderr();
}
$len = count($rows);
$j = 0;
$i = 0;
$result = "<div>ultime offerte".$name."</div>";
$result = $result."<table>";
while($j<5 && $j<$len) {
$query = "select `name`,`published` `#__sobi2_categories` `catid` = ".$rows[$i]->catid;
$db->setquery($query);
$rows1 = $db->loadobjectlist();
if($rows1[0]->published == 1) {
$query = "select `itemid`,`published` `#__sobi2_item` `itemid` = ".$rows[$i]->scheda;
$db->setquery($query);
$rows2 = $db->loadobjectlist();
if($rows2[0]->published == 1) {
$result = $result."<tr>";
$result = $result."<td width=\"60%\">".$rows1[0]->name."</td>";
$result = $result."<td width=\"40%\"><a href=http://" . $_server['http_host'] . $_server['request_uri']."?option=com_sobi2&sobi2task=ddshownotizia&sobi2id=".$rows[$i]->scheda.">".$rows[$i]->titolo."</a></td>";
$result = $result."</tr>";
$j++;
}
}
$i++;
}
$result = $result."</table>";
return $result;
}
}
?>
--------------------------
tmpl/default.php
code: select all
<?php // no direct access
defined( '_jexec' ) or die( 'restricted access' ); ?>
<?php echo $offerte; ?>
---------------------------
there others 2 file.. index.html , /tmpl/index.html
the code
code: select all
<html><body bgcolor="#ffffff"></body></html>
Comments
Post a Comment