Autore Topic: Errore recupero parametri da backend.  (Letto 3580 volte)

Offline havana7

  • Nuovo arrivato
  • *
  • Post: 21
    • Mostra profilo
Errore recupero parametri da backend.
« il: 23 Ott 2009, 02:07:50 »
Sono un novizio in php ma ho voluto provare lostesso.
Ho modificato un modulo in modo che mi mostrasse nello slide show che fa delle schede paganti ed in base alla categoria in cui sono al momento.

il modulo funziona perfettamente soltanto che per cambiare il campo che mi determina se pagano o meno bisogna intervenire sul php.
Siccome volevo poter cambiare il tipo del campo da backend ho cambiato la fine della query da così:

Codice: [Seleziona]
WHERE field.fieldid = '31' AND field.data_txt = '1'  )  AND catid = '$cat' AND catid IS NOT NULL)"
a così:

Codice: [Seleziona]
$ WHERE field.fieldid = '$fieldid' AND field.data_txt = '$fieldvalue'  )  AND catid = '$cat' AND catid IS NOT NULL)"
;

In questo modo $fieldid e $fieldvalue dovrebbero essere settati in questo modo se non sbaglio:

Codice: [Seleziona]
$fieldid = $params->get('SelectF');
$fieldvalue = $params->get('SelectFValue')

dove SelectF e SelectFValue sono i param name dell'xml.

Il fatto è che ricevo l'errore: Call to a member function get() on a non-object

Non sono in grado da solo di venirne a capo quindi vi posto l'intero codice del file helper.php (quello che ho modificato), quello di slider.php e di quello xml

Codice: [Seleziona]
<?php
/**
* SOBI2 Ad Slider helper file
* NOTE: THIS MODULE REQUIRES AN INSTALLED SOBI2 COMPONENT and GALLERY PLUGIN FOR IT !
*
* @version $Id: mod_adslider.php 0003 2009-09-05 
* @package SOBI2
* @subpackage modules

* @copyright (C) 2009 Solgalov Daniel clicker |at| lanitdv.ru
* module is based on Virtuemart ProductScroller module

* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
*
* SOBI2 is Free Software.
* SOBI2 comes with absolute no warranty.
*/



class modSobiAdsliderHelper
{
    
/**
     * Retrieves the hello message
     *
     * @param array $params An object containing the module parameters
     * @access public
     */

    function 
PrepareCustomHeader$params$cId$cl )
    {

        if (!
defined("_JQUERY")){
JHTML::script('jquery-1.3.2.min.js','modules/mod_sobi2adslider/jcarousel/lib/',false);
}
        
JHTML::script('jquery.jcarousel.pack.js','modules/mod_sobi2adslider/jcarousel/lib/',false);  
JHTML::script('adslider.helper.js','modules/mod_sobi2adslider/jcarousel/',false); 
        
JHTML::stylesheet('jquery.jcarousel.css''modules/mod_sobi2adslider/jcarousel/lib/');
        
JHTML::stylesheet('skin.css''modules/mod_sobi2adslider/jcarousel/skins/'.$params->get('SkinName').'/');
 


if (!defined("_JQUERY")){
$doc =&JFactory::getDocument();
$doc->addScriptDeclaration('jQuery.noConflict();');
define ("_JQUERY"true);
}

/* /// static content init 
        $js = 'jQuery(document).ready(function() {
            jQuery("#'.$cId.'").jcarousel({';

$js .= 'size:'.$cId.'_itemList.length,';

$js .= 'itemLoadCallback: {onBeforeAnimation:'.$cId.'._itemLoadCallback}';

if ($params->get('vertical')) $js .='vertical: true,';
if ($params->get('UseCustomEffect')) $js .= "easing: '".$params->get('CustomEffectName')."',";
if ($params->get('wrap') !='none') $js .= "wrap: '".$params->get('wrap')."',"; 
$js .= 'animation:'.$params->get('Animation').',';
$js .= 'auto:'.$params->get('AutoScroll').',';  
        $js .= 'scroll:'. $params->get('ItemsToScroll');

$js .= ' });
        });';
$doc->addScriptDeclaration($js);
*/


return 0;
    }
    


    function 
PrepareAdsDB($limit=0$how=null$imgsrc='gallery' ){
$cat = (int) sobi2Config::request($_REQUEST'catid'0);
$fieldid $params->get('SelectF');
    
$fieldvalue $params->get('SelectFValue');
$database =&JFactory::getDBO();
if($limit>0) {
$limit "LIMIT $limit";
} else {
$limit "";
}
// did not use SELECT * for faster query
if ($imgsrc == 'gallery'){


$query2 "SELECT item.title, relation.ordering, relation.catid, item.last_update, item.itemid, item.icon, relation.*"
." FROM `jos_sobi2_item` AS item LEFT JOIN `jos_sobi2_cat_items_relations`"
." AS relation ON item.itemid = relation.itemid"
." WHERE (item.itemid IN (SELECT field.itemid"
." FROM `jos_sobi2_fields_data` AS field"
." WHERE field.fieldid = '$fieldid' AND field.data_txt = '$fieldvalue'  )  AND catid = '$cat' AND catid IS NOT NULL)"

$database->setQuery$query2 );
$rows2 $database->loadObjectList();
$result2 mysql_query($query2) or die ("Error in query: $query. " mysql_error());

if( mysql_num_rows($result2) ==) { 
$pay 1;
} else {
 
$pay 2;



if ((
$cat!="") && ($pay!=1)) {



$query "SELECT item.title, relation.ordering, relation.catid, item.last_update, item.itemid, item.icon, relation.*"
." FROM `#__sobi2_item` AS item LEFT JOIN `#__sobi2_cat_items_relations`"
." AS relation ON item.itemid = relation.itemid"
." WHERE (item.itemid IN (SELECT field.itemid"
." FROM `#__sobi2_fields_data` AS field"
." WHERE field.fieldid = '$fieldid' AND field.data_txt = '$fieldvalue'  )  AND catid = '$cat' AND catid IS NOT NULL)"


}
else{ 
$query "SELECT item.title, relation.ordering, relation.catid, item.last_update, item.itemid, item.icon, relation.*"
." FROM `#__sobi2_item` AS item LEFT JOIN `#__sobi2_cat_items_relations`"
." AS relation ON item.itemid = relation.itemid"
." WHERE (item.itemid IN (SELECT field.itemid"
." FROM `#__sobi2_fields_data` AS field"
." WHERE field.fieldid = '$fieldid' AND field.data_txt = '$fieldvalue'  ))"

}

                    
}
else{


$query2 "SELECT item.title, relation.ordering, relation.catid, item.last_update, item.itemid, item.icon, relation.*"
." FROM `jos_sobi2_item` AS item LEFT JOIN `jos_sobi2_cat_items_relations`"
." AS relation ON item.itemid = relation.itemid"
." WHERE (item.itemid IN (SELECT field.itemid"
." FROM `jos_sobi2_fields_data` AS field"
." WHERE field.fieldid = '$fieldid' AND field.data_txt = '$fieldvalue'  )  AND catid = '$cat' AND catid IS NOT NULL)"

$database->setQuery$query2 );
$rows2 $database->loadObjectList();
$result2 mysql_query($query2) or die ("Error in query: $query. " mysql_error());

if( mysql_num_rows($result2) ==) { 
$pay 1;
} else {
 
$pay 2;



if ((
$cat!="") && ($pay!=1)) {


$query "SELECT item.title, relation.ordering, relation.catid, item.last_update, item.itemid, item.icon, relation.*"
." FROM `#__sobi2_item` AS item LEFT JOIN `#__sobi2_cat_items_relations`"
." AS relation ON item.itemid = relation.itemid"
." WHERE (item.itemid IN (SELECT field.itemid"
." FROM `#__sobi2_fields_data` AS field"
." WHERE field.fieldid = '$fieldid' AND field.data_txt = '$fieldvalue'  )  AND catid = '$cat' AND catid IS NOT NULL)"


}else{ 
$query "SELECT item.title, relation.ordering, relation.catid, item.last_update, item.itemid, item.icon, relation.*"
." FROM `#__sobi2_item` AS item LEFT JOIN `#__sobi2_cat_items_relations`"
." AS relation ON item.itemid = relation.itemid"
." WHERE (item.itemid IN (SELECT field.itemid"
." FROM `#__sobi2_fields_data` AS field"
." WHERE field.fieldid = '$fieldid' AND field.data_txt = '$fieldvalue'  ))"


}

                 
}
switch( $how ) {
case 'random':
$query .= "\n  ORDER BY RAND() $limit";
break;
case 'newest':
$query .= "\n ORDER BY ad.publish_up DESC $limit";
break;
case 'popular':
$query .= "\n ORDER BY ad.hits ASC $limit";
break;
default:
$query .= "\n ORDER BY ad.publish_up $limit";
break;
}
$database->setQuery$query );
$rows $database->loadObjectList();

if ( $database->getErrorNum() ) { 
      trigger_error"DB reports: ".$database->stderr(), E_USER_WARNING );
}


return $rows;

    }
    
    function 
DisplayAdsThumb($row,$imageSource,$noImagePath){

        
$url JRoute::_("index.php?option=com_sobi2&amp;sobi2Task=sobi2Details&amp;catid={$row->catid}&amp;sobi2Id={$row->itemid}&amp;Itemid=1"); //{$urltitle}";

if ($imageSource == 'gallery'){

    $db=&JFactory::getDBO();
    $q="SELECT thumb FROM #__sobi2_plugin_gallery WHERE itemid = {$row->itemid} ORDER BY 1";
    $db->SetQuery($q);
    $thumb $db->LoadResult();
    if ( $db->getErrorNum() ) { 
    trigger_error"DB reports: ".$db->stderr(), E_USER_WARNING );
    }
    if(! $thumb){
        $imgurl JURI::base().$noImagePath;
    }
    else{
  
$imgurl =JURI::base()."images/com_sobi2/gallery/{$row->itemid}/{$thumb}";
    }

else {
//If no images are in Icon field then...
            
if ($row->icon == '') {
        $imgurl JURI::base().$noImagePath;
    }
    else {
        $imgurl JURI::base()."images/com_sobi2/clients/{$row->icon}";
    } 
}
        
$result '{url :"'.$url'",imgurl :"'.$imgurl .'",title:"'.$row->title .'"}';
return $result;
 
    }

    
    function 
DisplaySlider($rows,$params){
$result '';

foreach($rows as $row){
             
$result .='<li>'modSobiAdsliderHelper::DisplayAdsThumb($row,$params->get('ImageSource'),$params->get('noImagePath')).'</li>';


return $result;

    }
    
     function 
PrepareDynamicList($rows,$params){
$result '';
foreach($rows as $row){
if($result =='')

             
      $result modSobiAdsliderHelper::DisplayAdsThumb($row,$params->get('ImageSource'),$params->get('noImagePath'));
else 
      $result .= ',
'
.modSobiAdsliderHelper::DisplayAdsThumb($row,$params->get('ImageSource'),$params->get('noImagePath'));

return $result;

    }

  
     
}
?>



slider.php
Codice: [Seleziona]
<?php
/**
* SOBI2 Ad Slider Module
* NOTE: THIS MODULE REQUIRES AN INSTALLED SOBI2 COMPONENT and GALLERY PLUGIN FOR IT !
*
* @version $Id: mod_adslider.php 0003 2009-09-05 
* @package SOBI2
* @subpackage modules

* @copyright (C) 2009 Solgalov Daniel clicker |at| lanitdv.ru
* module is based on Virtuemart ProductScroller module

* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
*
* SOBI2 is Free Software.
* SOBI2 comes with absolute no warranty.
*/

defined'_JEXEC' ) or die( 'Restricted access' );
 
// Include the syndicate functions only once
require_once( dirname(__FILE__).DS.'helper.php' );
 
///>>>>
$carouselid 'carouselID_'.$module->id;
$skin $params->get('SkinName');
$rows modSobiAdsliderHelper::PrepareAdsDB($params->get('NumberOfAds'), $params->get('ScrollSortMethod'),$params->get('ImageSource'));
$AdsliderOutput modSobiAdsliderHelper::DisplaySlider($rows,$params);
$jscriptlist =  modSobiAdsliderHelper::PrepareDynamicList($rows,$params);
modSobiAdsliderHelper::PrepareCustomHeader$params$carouselid$jscriptlist );

if (
$params->get('wrap')=='circular') require( JModuleHelper::getLayoutPath'mod_sobi2adslider','circular' ) );
else require( 
JModuleHelper::getLayoutPath'mod_sobi2adslider' ) );
?>






xml
Codice: [Seleziona]
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE install SYSTEM "http://dev.joomla.org/xml/1.5/module-install.dtd">
<install type="module" version="1.5.0">
<name>SOBI2 Ads Slider</name>
<creationDate>September 2009</creationDate>
<author>Dan Solgalov</author>
<authorEmail>clicker|at|lanitdv.ru</authorEmail>
<authorUrl>http://medical-ultrasound.ru</authorUrl>
<copyright>
Copyright (C) 2009 Dan Solgalov. All rights
reserved.
</copyright>
<license>http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL</license>
<version>0.0.3</version>
<description>Displays a SOBI2 Ads Slider.This module needs Sigsiu SOBI2 component to be installed. Module is based at JCarousel JQuery javascript, so read the JCarousel description to understand all the parameters. You can run as many AdSliders per page as you want without conflicts. Module widht, height and appearance are set in skin.css file of the appropriate skin folder. If you want to run multiple carousels with different appearance, just create a copy of a skin folder and give it to AdSlider as &#38;#34;SkinName&#38;#34; parameter. Note! Do not forget to rename css elements inside &#38;#34;skin.css&#38;#34; (if for example you made new skin folder named &#38;#34;Tango1&#38;#34;, just rename css properties in skin.css to &#38;#34;Tango1&#38;#34; too)
</description>
<files>
<filename module="mod_sobi2adslider">mod_sobi2adslider.php</filename>
<filename module="mod_sobi2adslider">index.html</filename>
<filename module="mod_sobi2adslider">tmpl/index.html</filename>

<filename module="mod_sobi2adslider">jcarousel/adslider.helper.js</filename>

<filename module="mod_sobi2adslider">jcarousel/lib/jquery.jcarousel.css</filename>
<filename module="mod_sobi2adslider">jcarousel/lib/jquery.jcarousel.js</filename>
<filename module="mod_sobi2adslider">jcarousel/lib/jquery.jcarousel.pack.js</filename>
<filename module="mod_sobi2adslider">jcarousel/lib/jquery-1.3.2.min.js</filename>

<filename module="mod_sobi2adslider">jcarousel/skins/ie7/skin.css</filename>
<filename module="mod_sobi2adslider">jcarousel/skins/ie7/loading_small.gif</filename>
<filename module="mod_sobi2adslider">jcarousel/skins/ie7/next-horizontal.gif</filename>
<filename module="mod_sobi2adslider">jcarousel/skins/ie7/prev-horizontal.gif</filename>
<filename module="mod_sobi2adslider">jcarousel/skins/ie7/loading-small.gif</filename>
<filename module="mod_sobi2adslider">jcarousel/skins/ie7/loading.gif</filename>

<filename module="mod_sobi2adslider">jcarousel/skins/tango/skin.css</filename>
<filename module="mod_sobi2adslider">jcarousel/skins/tango/next-horizontal.png</filename>
<filename module="mod_sobi2adslider">jcarousel/skins/tango/prev-horizontal.png</filename>
<filename module="mod_sobi2adslider">jcarousel/skins/tango/next-vertical.png</filename>
<filename module="mod_sobi2adslider">jcarousel/skins/tango/prev-vertical.png</filename>

<filename>helper.php</filename>
                <filename>tmpl/default.php</filename>
<filename>tmpl/circular.php</filename>

</files>
<params>

<param name="NumberOfAds" type="text" default="5"
label="Number of Ads"
description="The Number of Ads of the Slide Carousel" />

<!-- Start Entry Selection Criteria -->
 
 <param name="SelectF" label="LABEL:SELECT-CUSTOM-FIELD-ID" default="1" type="sql" key_field="fieldid" value_field="langKey" query="SELECT t1.fieldid, t1.langKey FROM #__sobi2_language AS t1, #__sobi2_config AS t2 WHERE t1.sobi2Section = 'fields' AND t2.configKey = 'language' AND t1.sobi2Lang LIKE IF(t2.configValue='default','english',CONCAT('%',SUBSTRING(t2.configValue,2),'%'))" description="DESC:SELECT-CUSTOM-FIELD-ID" />
 
 <param name="SelectOperator" label="LABEL:SELECT-OPERATOR" default="0" type="radio" description="DESC:SELECT-OPERATOR">
<option value="0">OPTION:EQUALS</option>
<option value="1">OPTION:SQL-LIKE</option>
</param>
 <param name="SelectFValue" type="text" size="15" default="" label="LABEL:SELECT-CUSTOM-FIELD-VALUE" description="DESC:SELECT-CUSTOM-FIELD-VALUE" />
<!-- End Entry Selection Criteria -->

<param name="ImageSource" type="radio" default="icon"
label="From where to take preview pictures?"
description="Will take pictures from Icon or from Gallery">
<option value="icon">From Icon</option>
<option value="gallery">From Gallery</option>
</param>

<param name="noImagePath" type="text" default="components/com_sobi2/templates/standard_advanced/nopic.jpg" label="Path to No Image picture"
description="Type the path to noimage picture here" />


<param name="ScrollSortMethod" type="radio" default="random"
label="What Order the Ads shall be displayed?"
description="Defines the display order of the products.">
<option value="newest">Newest</option>
<option value="popular">Popular</option>
<option value="random">Random</option>
</param>

<param name="vertical" type="radio" default="0"
label="Is the slider vertical?"
description=" Horizontal or Vertical">
<option value="0">No</option>
<option value="1">Yes</option>

</param>
<param name="SkinName" type="text" default="tango" label="Skin Name"
description="ie7, tango, or your own" />


<param name="ItemsToScroll" type="text" default="2" label="Items To Scroll By"
description="Items To Scroll By per one button press" />

<param name="wrap" type="list" default="none" label="wrap (see JCarousel docs)" description="What to do when last item is reached and prev-next button pressed">
<option value="none">none</option>
<option value="first">First</option>
<option value="last">Last</option>
<option value="both">Both</option>
<option value="circular">Circular</option>
</param>

<param name="UseCustomEffect" type="radio" default="1"
label="Use Custom Effects?"
description="Use Custom Effects from file: adslider.helper.js?">
<option value="0">No</option>
<option value="1">Yes</option>
</param>
<param name="CustomEffectName" type="text" default="BounceEaseOut" label="Custom Effect Function Name"
description="Add your own JQuery custom bouncing effects to adslider.helper.js" />

<param name="AutoScroll" type="text" default="0" label="Carousel Auto Slide (seconds)"
description="Time(in seconds) of Auto Slide" />

<param name="Animation" type="text" default="1000" label="Animation time (msec)"
description='Can be &#38;#38;&#38;#113;&#38;#117;&#38;#111;&#38;#116;;fast&#38;#38;&#38;#113;&#38;#117;&#38;#111;&#38;#116;;, &#38;#38;&#38;#113;&#38;#117;&#38;#111;&#38;#116;;slow&#38;#38;&#38;#113;&#38;#117;&#38;#111;&#38;#116;; or milliseconds'  />



</params>
</install>

« Ultima modifica: 23 Ott 2009, 02:20:13 da havana7 »

Offline havana7

  • Nuovo arrivato
  • *
  • Post: 21
    • Mostra profilo
Re:Errore recupero parametri da backend.
« Risposta #1 il: 23 Ott 2009, 19:18:51 »
non riesco a capire...

fuori da questa funzione:

Codice: [Seleziona]
function PrepareAdsDB($params, $limit=0, $how=null, $imgsrc='gallery' ){
$fieldid = $params->get('SelectF');
$fieldvalue = $params->get('SelectFValue')

mi vengono tranquillamente presi

dentro invece mi da il Call to a member function get() on a non-object

 

Host

Torna su