Zum Inhalt springen

html template einbinden gar kein plan

Erstellt am 29. Mai 2007 · 16 Antworten · letzte Antwort am 12. Juli 2007

Tags: Frage

nugget ·

Hallo Forum ich habe mir mit dem kickstarter eine extension gestrickt (frontendplugin)! diese enthählt 2 tabellen und ein frontendplugin die eine tabelle hat eine datenbank relation auf die andere. ich kann inhalte im backend anlegen und bekomme diese auch im frontend ausgegeben über die standart ausgabe die man vom kickstarter bekommt!

da ich die ausgabe ein bissi anderst gestalten will habe ich mir dieses hier angeschaut

http://wiki.typo3.org/index.php/Extension_Development%2C_using_HTML-Templates

also habe ich meine mainfunction

/**
* 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;
		}
	}

durch diese ersetzt:

# Get the template
$this->templateCode = $this->cObj->fileResource($conf['templateFile']);
 
# Get the parts out of the template
$template['total'] = $this->cObj->getSubpart($this->templateCode,'###TEMPLATE###');
  
# create the content by replacing the marker in the template
$markerArray['###MARKER1###'] = 'content for marker 1';
$markerArray['###MARKER2###'] = 'content for marker 2';

$content = $this->cObj->substituteMarkerArrayCached($template['total'],$markerArray);
return $content;

und bekomme nun diesen fehler:

Parse error: parse error, unexpected T_VARIABLE, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /var/web/www.feuerwehr-zimmern.de/htdocs/typo3conf/ext/byteaction_firemissions/pi1/class.tx_byteactionfiremissions_pi1.php on line 49

liegt es an dem tutorial oder an mir??

just2b ·

Hallo,

bitte verwende für php nicht die TS-Codeboxen sondern die für PHP und welche Zeile die 49 bei dir ist soll man raten?

georg
PS: Du testest mit 4.2.? sollte man nicht tun wenn man nicht muss (siehe signatur)

nugget ·

da hab ich den profi an der angel :-)

zeile 49 ist folgende

# Get the template
$this->templateCode = $this->cObj->fileResource($conf['templateFile']);
just2b ·

Hast du denn in deinem Setup den Pfad zum Template angegeben, also so

plugin.tx_deineext_pi1.templateFile = fileadmin/deintemplate.html

?

zum testen überschreib in zeile 49 doch das

$conf['templateFile']

mit dem Pfad zum Template

georg

nugget ·

Also template liegt in fileadmin/template.html

in die datei ext: static/Setup/setup.txt habe ich folgendes reingeschrieben:
plugin.tx_firemissions_pi1.templateFile = fileadmin/template.html

und zeile 49 sieht jetzt so aus:

# Get the template
#$this->templateCode = $this->cObj->fileResource($conf['templateFile']);
 $conf['templateFile']
nugget ·

es kommt wieder

Parse error: parse error, unexpected T_VARIABLE, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /var/web/www.feuerwehr-zimmern.de/htdocs/typo3conf/ext/byteaction_firemissions/pi1/class.tx_byteactionfiremissions_pi1.php on line 50

nur halt in zeile 50 da ich zeile 49 auskommentiert habe

just2b ·

stell mal das ganze online, zB auf phpfi.com mit zeilenangabe des aktuellen fehlers

georg

just2b ·

du kannst nicht einfach so irgendnen code in php platzieren. das geht in TS, aber nicht in php!

so sollte es eigentlich schon funktionieren

<?
    $this->templateCode = $this->cObj->fileResource('fileadmin/template.html');
    # $conf['templateFile']
     
    # Get the parts out of the template
    $template['total'] = $this->cObj->getSubpart($this->templateCode,'###TEMPLATE###');
  
    # create the content by replacing the marker in the template
    $markerArray['###MARKER1###'] = 'content for marker 1';
    $markerArray['###MARKER2###'] = 'content for marker 2';

    $content = $this->cObj->substituteMarkerArrayCached($template['total'],$markerArray);
    return $content; 
?>

georg

nugget ·

danke für deine antwort aber leider funktioniert es immer noch nicht bekomme folgende fehler meldung:

Parse error: parse error, unexpected T_VARIABLE, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /var/web/www.feuerwehr-zimmern.de/htdocs/typo3conf/ext/byteaction_firemissions/pi1/class.tx_byteactionfiremissions_pi1.php on line 49

hier der code:
http://phpfi.com/238081

just2b ·

häng mal an die url ein no_cache=1 an, bin mir nicht sicher ob die 2 zusammenpassen...

georg

nugget ·

funktioniert auch nicht!!!

wie gesagt das das erste mal das ich extension selbst erstelle ich hab immer nur gehört das soll so einfach sein. warum funzt das dann bei mir nicht #angry#

nugget ·

Also ich habe es jetzt mit folgendem code geschafft das er mir "Kein Template gefunden" ausgibt:

function main($content,$conf)	
{
	$this->conf=$conf;
	$this->pi_setPiVarDefaults();
	$this->pi_loadLL();

	// No cache
	#$GLOBALS["TSFE"]->set_no_cache();

	$this->templateFile = $this->conf['templateFile'];
	if (!$templateFile) 
	{
		return'<h1>Kein Template gefunden</h1>';
		#$templateFile = 'res/template.html';
	}
	$this->templateCode = $this->cObj->fileResource($conf['templateFile']);

	#Get the parts out of the template
	$template['total'] = $this->cObj->getSubpart($this->templateCode,'###TEMPLATE###');

	# create the content by replacing the marker in the template
	$markerArray['###MARKER1###'] = 'content for marker 1';
	$markerArray['###MARKER2###'] = 'content for marker 2';
	
	$content = $this->cObj->substituteMarkerArrayCached($template['total'],$markerArray);
	return $content;  
}

obwohl er doch eigentlich folgendes html template ausgeben müsste was in res/template.html zu finden ist:

<h3>TEMPLATE</h3>
<em>This is a simple HTML-Template</em> 
<!-- ###TEMPLATE### begin -->
 <h1>###MARKER1###</h1><h1>###MARKER2###</h1>
<!-- ###TEMPLATE### end -->

weil ich das template ja mit

plugin.tx_byteaction_firemissions_pi1 {
	templateFile = res/template.html
}

aus der datei static/Setup/setup.txt anspreche

oder irre ich mich da??

just2b ·

templateFile = res/template.html

das geht schon von root aus, und da gibt es in aller regel kein res/ .. also eher ein

templateFile = EXT:deinextkey/res/template.html

georg

nugget ·

yippi habe es hinbekommen das mein template eingelesen wird!

ich habe das template (template.html) in das verzeichnis pi1/ kopiert und den pfad in der Datei ext_typoscript_setup.txt angepasst:

plugin.tx_byteactionfiremissions_pi1.templateFile = EXT:byteaction_firemissions/pi1/template.html
Php_Diver ·

hallo nugget,

habe gerade das selbe problem.
auch bei mir schreibt er "Kein Template gefunden".
danach verschob ich mein template nach pi1 und habe die pfade angepasst. leider ändert sich bei mir überhaupt nichts.

hast du einen tip für mich?

danke

nugget ·

na wie schon gesagt bei mir hat es funktioniert indem ich mein template in den ordner "pi1" verschoben habe und dann in der datei ext_typoscript_setup.txt (die sich im Hauptverzeichnis der Extension befindet folgendes TS eingetragen habe

plugin.tx_DEINEXTENSIONNAME_pi1.templateFile = EXT:DEINEXTENSIONNAME/pi1/template.html

Ich hoffe ich konnte dir damit helfen leider bin ich auch net gerade ein Schlaufuchs auf diesem Gebiet!

Good Luck