Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Two Pass Compilierung

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Language: German
View previous topic :: View next topic  
Author Message
coach
Smarty Regular


Joined: 03 Jun 2004
Posts: 65

PostPosted: Thu Jul 08, 2004 7:05 am    Post subject: Two Pass Compilierung Reply with quote

Hallo,

mein System sieht wie folgt aus, im PHP-Script weise ich meinem Smarty-Objekt eine Reihe von Objekten und ein Content-Template zu und dann der display()

Das Master-Template ist ungefähr wie folgt aufgebaut:
Code:

<html>
  <head>
    <title>{$title|default:"..."}</title>
    <meta name="keywords" content="{$keywords|default:"..."}"/>
    <meta name="description" content="{$description|default:"...."}"/>
  </head>
<body>
{include file=$content}
</body>
</html>


Bisher setze (assign) ich im PHP-Script den Title, die Keywords und die Description. Das gefällt mir aber nicht ganz, da ich ja zum Teil in den Content-Templates die Überschriften <h1> setze, die ja ähnlich dem Title etc. sind.

Ich würde das gerne auch im Template machen (also die Logik für den Title etc.), aber beim Include des Content-Template ist ja der head der Datei schon geschrieben.

Mal davon abgesehen, ob nach Trennung von Logik und Layout das Content-Template die richtige Stelle zum Setzen des Heads ist, welche Möglichkeiten habe ich?

A)
Das Content-Template zweimal includen und per Mode steuern, ob jetzt der Title etc. "berechnet" wird (assign im Template) oder der Content ausgegeben werden soll. Zwei Templates möchte ich nicht unbedingt verwenden.

B)
Über einen Mechanismus, bei dem ich nicht weiß, ob der mit Plugins zu realisieren ist, der am Ende der Seitenerzeugung oben den Title setzt. Also das eigentliche Two Pass.

C)
Im Content-Template per Plugins etc. eine Funktion im compilierten Template erzeugen, die dann oben im head aufgerufen wird. Könnte man das realisieren?

Wie könnte ich mein Problem noch lösen?


Coach
Back to top
View user's profile Send private message
till
Smarty Rookie


Joined: 25 Feb 2004
Posts: 19
Location: Berlin, Germany

PostPosted: Thu Jul 08, 2004 12:35 pm    Post subject: Reply with quote

Ich versteh die Frage nicht ganz, sorry. Mal sehen...

Du formatierst ausserhalb Deines Templates einige Texte und fuegst dann zum Beispiel <h1> ein, usw..? Wenn's nur das ist, wuerde ich den Modifier strip_tags benutzen.

Ich persoenlich glieder alles so, dass ausserhalb des Templates die nakten Fakten sind. Heisst, Werte ohne jegliche Formatierung. Formatierung nehme ich dann innerhalb des Templates vor, bzw.. ich ueberlass das dem Designer. Smile

Till
Back to top
View user's profile Send private message
coach
Smarty Regular


Joined: 03 Jun 2004
Posts: 65

PostPosted: Thu Jul 08, 2004 1:18 pm    Post subject: Reply with quote

Hi Till,

ich mache z.B.
Code:

$my_smarty->assign('divecenter', $my_divecenter);

daraus sollte im Template dann der Title-Tag und einige Meta-Tags geschrieben werden (neben dem Content natürlich). Problem ist aber,
das Content-Template wird eigentlich erst nach dem HTML-Kopf includiert. z.B. wird im Template ja auch je nach Sprache noch das Wort "Tauchbasen" oder "Dive Centers" hinzugefügt.

Momentan "berechne" ich halt im PHP-Script die ganzen Tags, aber theoretisch ist doch HTML das Layout, also muß die Logik für den HTML-Kopf auch ins Template. Wenn ich z.B. WML oder RDF hätte, bräuchte ich ja keine Meta-Tags - also klare Trennung von Logik und Layout. Oder nicht?


Coach
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Language: German All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP