Zum Inhalt springen

Ext mit eigenen Klassen erweitern

Erstellt am 15. Juli 2007 · 21 Antworten · letzte Antwort am 20. Juli 2007 · Seite 2 von 2

Tags: Frage

steffenk ·

hast Du auch instanziert? Hast Du auch die init aus der Hauptklasse aufgerufen ? Hast Du auch die Reihenfolge gleich ?

$b->init($this->conf,$this)
...
function init(&$conf,&$pibase) {
...

Knalltuete ·
$b->init($this->conf,$this)
...
function init(&$conf,&$pibase) {
...

so hab ich es gemacht.

Irgendwie bin ich doof.. aber ich moecht es endlich verstehen 🙁

steffenk ·

ok, hier das komplette Beispiel:

<?php
/***************************************************************
*  Copyright notice
*
*  (c) 2007  <>
*  All rights reserved
*
*  This script is part of the TYPO3 project. The TYPO3 project is
*  free software; you can redistribute it and/or modify
*  it under the terms of the GNU General Public License as published by
*  the Free Software Foundation; either version 2 of the License, or
*  (at your option) any later version.
*
*  The GNU General Public License can be found at
*  http://www.gnu.org/copyleft/gpl.html.
*
*  This script is distributed in the hope that it will be useful,
*  but WITHOUT ANY WARRANTY; without even the implied warranty of
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*  GNU General Public License for more details.
*
*  This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/

require_once(PATH_tslib.'class.tslib_pibase.php');
require_once(t3lib_extMgm::extPath('dummy').'pi1/class.tx_dummy_ext.php');   



/**
 * Plugin 'Dummy FE' for the 'dummy' extension.
 *
 * @author	 <>
 * @package	TYPO3
 * @subpackage	tx_dummy
 */
class tx_dummy_pi1 extends tslib_pibase {
	var $prefixId      = 'tx_dummy_pi1';		// Same as class name
	var $scriptRelPath = 'pi1/class.tx_dummy_pi1.php';	// Path to this script relative to the extension dir.
	var $extKey        = 'dummy';	// The extension key.
	var $pi_checkCHash = true;
	
	/**
	 * The main method of the PlugIn
	 *
	 * @param	string		$content: The PlugIn content
	 * @param	array		$conf: The PlugIn configuration
	 * @return	The content that is displayed on the website
	 */
	function main($content,$conf)	{
		$this->conf=$conf;
		$this->pi_setPiVarDefaults();
		$this->pi_loadLL();
		
	    $b = t3lib_div::makeInstance('tx_dummy_ext');
        $b->init($this->conf,$this);
		$content=$b->sayHello();
	
	
		return $this->pi_wrapInBaseClass($content);
	}
}



if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dummy/pi1/class.tx_dummy_pi1.php'])	{
	include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dummy/pi1/class.tx_dummy_pi1.php']);
}

?>

und die eingebundene:

<?php

class tx_dummy_ext  {

    function init(&$conf,&$pibase) {
        $this->conf = $conf;
        $this->pibase = $pibase;
    }
  
    function sayHello() {
        return 'Hello';
    }
}       
?>
Knalltuete ·

ok kapiert! funzt soweit auch, jedoch bleibt er jetzt bei der funktion

$this->cObj->fileResource($file)

in der klasse b haengen. Liegt das an dem cObj?

steffenk ·

in der Nebenklasse:

function sayHello() {
  return $this->pibase->cObj->calc('3+4');
}

Ich glaube hier hängts:

Hauptklasse erweitert pibase, also ist $this auch pibase.
cObj ist ein Objekt der pibase, also erreichbar über $this->cObj

in der Nebenklasse über die Hauptklasse:
$this->pibase->cObj

Knalltuete ·

VERDAMMT ES GEHT! :o
YEEEEHAAA 😃

woa ich danke dir von herzen 🙂
endlich kann ich loslegen zu programmieren!

aber komisch.. das hatte ich glaube schon probiert aber es lief net.. naja hauptsache es geht jetzt!

Nochmals vielen vielen herzlichen danke!
ich glaub ich checks jetzt auch 🙂

danke fuer die unglaubliche geduld!

mfg stefan 😃

Harakiri ·

Aber es ist doch Käse dass ich die Variablen übergeben muss! Warum kann ich nicht einfach die "Membervariablen" der Oberklasse aufgreifen? Normalerweise kenn ich das von OOP so.
Scheint aber in php4 nicht zu gehen oder?

steffenk ·

wenn das Käse für Dich ist, dann zeig uns doch einen Weg ohne - Du kennst ja OOP, also kein Problem 😉

Harakiri ·
steffenk schrieb

wenn das Käse für Dich ist, dann zeig uns doch einen Weg ohne - Du kennst ja OOP, also kein Problem 😉

Ja eben es geht halt nicht mit php4, es sei denn man würde alles auf Sessions oder so umlegen. Naja, warten wir halt auf php5......und harren der Dinge, Harry. #angry#