Zum Inhalt springen

Extension-Parameter verwenden

Erstellt am 13. Juli 2010 · 2 Antworten · letzte Antwort am 13. Juli 2010

Tags: Frage

stuurs ·

Guten Tag allerseits

Hänge mal wieder an einem Problem, welches wahrscheinlich simpelst zu lösen ist. Leider nicht für mich :-(

Habe einer eigenen Extension einen Extension Parameter verpasst. Im zugehörigen FE-Plugin kann ich diesen Wert mit

$lConf = unserialize($TYPO3_CONF_VARS['EXT']['extConf']['nwjp']);
$FWJahr = $lConf['fwjahr'];

auslesen

Nun meine Frage:
In meinem Plugin erfolgt weiter unten mal eine Listview-Ausgabe von Datensätzen. Die vorgängige DB-Abfrage enthält eine WHERE-Klausel in der der Parameter $FWJahr verwendet werden sollte. Da kann ich aber auf diese Variable nicht zugreifen!

Hier mal der Code bis zur besagten Stelle:

$lConf = unserialize($TYPO3_CONF_VARS['EXT']['extConf']['nwjp']);
$FWJahr = $lConf['fwjahr'];
//echo 'FW-Jahr = '.$FWJahr;
 
 
class tx_nwjp_pi1 extends tslib_pibase {
    var $prefixId      = 'tx_nwjp_pi1';        // Same as class name
    var $scriptRelPath = 'pi1/class.tx_nwjp_pi1.php';    // Path to this script relative to the extension dir.
    var $extKey        = 'nwjp';    // The extension key.
   
    /**
     * Main method of your PlugIn
     *
     * @param    string        $content: The content of the PlugIn
     * @param    array        $conf: The PlugIn Configuration
     * @return    The content that should be displayed on the website
     */
    function main($content, $conf)    {
       
        switch((string)$conf['CMD'])    {
            case 'singleView':
                list($t) = explode(':',$this->cObj->currentRecord);
                $this->internal['currentTable']=$t;
                $this->internal['currentRow']=$this->cObj->data;
                return $this->pi_wrapInBaseClass($this->singleView($content, $conf));
            break;
            default:
                if (strstr($this->cObj->currentRecord,'tt_content'))    {
                    $conf['pidList'] = $this->cObj->data['pages'];
                    $conf['recursive'] = $this->cObj->data['recursive'];
                }
                return $this->pi_wrapInBaseClass($this->listView($content, $conf));
            break;
        }
    }
   
    /**
     * Shows a list of database entries
     *
     * @param    string        $content: content of the PlugIn
     * @param    array        $conf: PlugIn Configuration
     * @return    HTML list of table entries
     */
    function listView($content, $conf) {
        $this->conf = $conf;        // Setting the TypoScript passed to this function in $this->conf
        $this->pi_setPiVarDefaults();
        $this->pi_loadLL();        // Loading the LOCAL_LANG values
        $this->pi_USER_INT_obj = 1;    // Configuring so caching is not expected. This value means that no cHash params are ever set. We do this, because it's a USER_INT object!
        $lConf = $this->conf['listView.'];    // Local settings for the listView function

        if ($GLOBALS['TSFE']->id == 89) {
            $adWhere = 'AND ujpad = 1 AND uyear = '.$FWJahr;
        } else {
            $adWhere = 'AND ujpad = 0 AND uyear = '.$FWJahr;
        }

Danke im Voraus für eure Hilfe

Mopps ·

"Da kann ich aber auf diese Variable nicht zugreifen!"
Kommt denn eine Fehlermeldung bei der DB-Abfrage? Wenn ja, welche?

stuurs ·

😃: Gelöst!
Nein, absolut keine Fehlermeldung in Sicht...

Die Lösung sieht so aus:

class tx_nwjp_pi1 extends tslib_pibase {
	var $prefixId      = 'tx_nwjp_pi1';		// Same as class name
	var $scriptRelPath = 'pi1/class.tx_nwjp_pi1.php';	// Path to this script relative to the extension dir.
	var $extKey        = 'nwjp';	// The extension key.
	var $FWJahr;

	/**
	 * Main method of your PlugIn
	 *
	 * @param	string		$content: The content of the PlugIn
	 * @param	array		$conf: The PlugIn Configuration
	 * @return	The content that should be displayed on the website
	 */
	function main($content, $conf)	{
		
		/** 
		Feuerwehrjahr holen aus Extension-Parameter
		*/
		$fwconf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$this->extKey]);
		$this->FWJahr = $fwconf['fwjahr'];
		
		switch((string)$conf['CMD'])	{
			case 'singleView':
				list($t) = explode(':',$this->cObj->currentRecord);
				$this->internal['currentTable']=$t;
				$this->internal['currentRow']=$this->cObj->data;
				return $this->pi_wrapInBaseClass($this->singleView($content, $conf));
			break;
			default:
				if (strstr($this->cObj->currentRecord,'tt_content'))	{
					$conf['pidList'] = $this->cObj->data['pages'];
					$conf['recursive'] = $this->cObj->data['recursive'];
				}
				return $this->pi_wrapInBaseClass($this->listView($content, $conf));
			break;
		}
	}
	
	/**
	 * Shows a list of database entries
	 *
	 * @param	string		$content: content of the PlugIn
	 * @param	array		$conf: PlugIn Configuration
	 * @return	HTML list of table entries
	 */
	function listView($content, $conf) {
		$this->conf = $conf;		// Setting the TypoScript passed to this function in $this->conf
		$this->pi_setPiVarDefaults();
		$this->pi_loadLL();		// Loading the LOCAL_LANG values
		$this->pi_USER_INT_obj = 1;	// Configuring so caching is not expected. This value means that no cHash params are ever set. We do this, because it's a USER_INT object!
		$lConf = $this->conf['listView.'];	// Local settings for the listView function		
		
		if ($GLOBALS['TSFE']->id == 89) {
			$adWhere = 'AND ujpad = 1 AND uyear = '.$this->FWJahr;
		} else {
			$adWhere = 'AND ujpad = 0 AND uyear = '.$this->FWJahr;
		}

Danke für die Hilfe.