Passar parâmetros para modulo
Enviado: 10 Abr 2009, 23:20
Estou tentando fazer algumas alterações para um modulo que exibe anuncios a partir de entradas do componente com_sobi2 no Joomla 1.5, mas me deparei com algumas dificuldades no uso do $params->get pois o componente utiliza a seguinte forma
Preciso utilizar de duas variáveis uma com o número do campo e outra com o valor do mesmo no sql a seguir:
O valor das variáveis já foi declarado no arquivo xml do modulo tentei declarar as duas variaveis da forma convencional :
$variavel1 = $params->get( 'Valor variavel 1' ) no começo da função acima mas recebo o erro Fatal error: Call to a member function get() on a non-object
A forma de declaração de variaveis citada no começo do post me parece orientada a objeto , por favor alguem me de uma pista
segue em anexo o modulo com as alterações que fiz .
Código: Selecionar todos
@var $NumberOfAds
*/
var $NumberOfAds = 5;
/**
* // scroll, alternate, slide
* @var $ScrollBehavior
*/
var $ScrollBehavior = 'scroll';
/**
* @var $PS_DIRECTION
*/
var $ScrollDirection = 'up';
/**
* @var $ScrollHeight
*/
var $ScrollHeight = '125';
/**
* @var $ScrollWidth
*/
var $ScrollWidth = '150';
/**
* @var $ScrollAmount
*/
var $ScrollAmount = '2';
/**
* @var $ScrollDelay
*/
var $ScrollDelay = '80';
/**
* @var $ScrollAlign
*/
var $ScrollAlign = 'center';
/**
* // newest [asc], oldest [desc], random [rand]
* @var $SortMethod
*/
var $ScrollSortMethod = 'random';
/**
* @var $ScrollTitles
*/
var $ScrollTitles = 'yes';
/**
* @var $ScrollSpaceChar
*/
var $ScrollSpaceChar = ' ';
/**
* @var $ScrollSpaceCharTimes
*/
var $ScrollSpaceCharTimes = 5;
/**
* @var $ScrollLineChar
*/
var $ScrollLineChar = '<br />';
/**
* @var $ScrollLineCharTimes
*/
var $ScrollLineCharTimes = 2;
/**
* @var $ScrollSection
*/
var $ScrollSection = 0;
// CSS override -----------------------
/**
* @var $ScrollCSSOverride
*/
var $ScrollCSSOverride = 'no';
/**
* @var $ScrollTextAlign
*/
var $ScrollTextAlign = 'left';
/**
* @var $ScrollTextWeight
*/
var $ScrollTextWeight = 'normal';
/**
* @var $ScrollTextSize
*/
var $ScrollTextSize = '10';
/**
* @var $ScrollTextColor
*/
var $ScrollTextColor = '#000000';
/**
* @var $ScrollBGColor
*/
var $ScrollBGColor = 'transparent';
/**
* @var $ScrollMargin
*/
var $ScrollMargin = '2';
/**
* @var $ImageSource
*/
var $ImageSource = 'gallery';
/**
* @var $noImagePath
*/
var $noImagePath = 'noimages.gif';
var $params = null;
/**
* set mammeters
*/
function adScroller (&$params) {
$this->params = $params;
// standard mammeters
$this->category_id = intval( $params->get('category_id', 0 ) );
// Limit by NoP
$this->NumberOfAds = $params->get('NumberOfAds', $this->NumberOfAds);
$this->ImageSource =$params->get('ImageSource', $this->ImageSource);
$this->noImagePath =$params->get('noImagePath', $this->noImagePath);
$this->ScrollSection = $params->get('ScrollSection', $this->ScrollSection);
$this->ScrollBehavior = $params->get('ScrollBehavior', $this->ScrollBehavior);
$this->ScrollDirection = $params->get('ScrollDirection', $this->ScrollDirection);
$this->ScrollHeight = $params->get('ScrollHeight', $this->ScrollHeight);
$this->ScrollWidth = $params->get('ScrollWidth', $this->ScrollWidth);
$this->ScrollAmount = $params->get('ScrollAmount', $this->ScrollAmount);
$this->ScrollDelay = $params->get('ScrollDelay', $this->ScrollDelay);
$this->ScrollAlign = $params->get('ScrollAlign', $this->ScrollAlign);
$this->ScrollSortMethod = $params->get('ScrollSortMethod', $this->ScrollSortMethod);
$this->ScrollTitles = $params->get('ScrollTitles', $this->ScrollTitles);
$this->ScrollSpaceChar = $params->get('ScrollSpaceChar', $this->ScrollSpaceChar);
$this->ScrollSpaceCharTimes = $params->get('ScrollSpaceCharTimes', $this->ScrollSpaceCharTimes);
$this->ScrollLineChar = $params->get('ScrollLineChar', $this->ScrollLineChar);
$this->ScrollLineCharTimes = $params->get('ScrollLineCharTimes', $this->ScrollLineCharTimes);
// customization mammeters
$this->ScrollCSSOverride = $params->get('ScrollCSSOverride', $this->ScrollCSSOverride);
$this->ScrollTextAlign = $params->get('ScrollTextAlign', $this->ScrollTextAlign);
$this->ScrollTextWeight = $params->get('ScrollTextWeight', $this->ScrollTextWeight);
$this->ScrollTextSize = $params->get('ScrollTextSize', $this->ScrollTextSize);
$this->ScrollTextColor = $params->get('ScrollTextColor', $this->ScrollTextColor);
$this->ScrollBGColor = $params->get('ScrollBGColor', $this->ScrollBGColor);
$this->ScrollMargin = $params->get('ScrollMargin', $this->ScrollMargin);
}
Preciso utilizar de duas variáveis uma com o número do campo e outra com o valor do mesmo no sql a seguir:
Código: Selecionar todos
$query = "SELECT ad.itemid, ac.catid, ac.ordering, ad.title, ad.last_update
FROM (#__sobi2_cat_items_relations AS ac, #__sobi2_fields_data AS fd)";
$query .="\nJOIN #__sobi2_item AS ad ON (ad.itemid = ac.itemid) AND (ad.itemid = fd.itemid) WHERE fd.fieldid = $variavel1 AND fd.data_txt =$variavel2 AND ad.published = 1";
} else{
$query = "SELECT ad.itemid, ac.catid, ac.ordering, ad.title, ad.icon, ad.last_update FROM (#__sobi2_cat_items_relations AS ac, #__sobi2_fields_data AS fd)";
$query .="\nJOIN #__sobi2_item AS ad ON (ad.itemid = ac.itemid) AND (ad.itemid = fd.itemid) WHERE fd.fieldid = $variavel1 AND fd.data_txt = $variavel2 AND ad.published = 1";
$variavel1 = $params->get( 'Valor variavel 1' ) no começo da função acima mas recebo o erro Fatal error: Call to a member function get() on a non-object
A forma de declaração de variaveis citada no começo do post me parece orientada a objeto , por favor alguem me de uma pista
segue em anexo o modulo com as alterações que fiz .