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

JavaScript immer im Header

 
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
Grizzly
Smarty Pro


Joined: 15 Apr 2011
Posts: 172
Location: Germany

PostPosted: Thu Apr 19, 2012 11:09 am    Post subject: JavaScript immer im Header Reply with quote

Hallo,

ich habe mal eine Frage, kann man es irgendwie schaffen, dass beim verwenden eines Speziellen Smarty-Tag (selbstgeschriebenes plugin) die übergebene URL immer ein
Code:
<script src="übergebene paramater" type="text/javascript"></script>


ausgibt und zwar IMMER an einer bestimmten Stelle (in meinem speziellen fall immer im Header (<head>-Tag)).

Beispiel:

es wird header.tpl geladen (beinhaltet den <head>-Tag) es wird danach template1.tpl geladen danach template2.tpl

in teamplate2.tpl wird ein Smarty-Tag verwendet (z. B. {myscript src="js.js"}) und diese JS-Datei soll nun im Template "header.tpl" an eine Bestimmte Stelle (Platzhalter) eingefügt werden.

Geht das? Ich möchte nämlich erreichen, dass JS-Files immer im Header stehen das selbe gilt dann auch für CSS-Files, allerdings dann mit einem anderen Smarty-PlugIn
Back to top
View user's profile Send private message Visit poster's website
rodneyrehm
Administrator


Joined: 30 Mar 2007
Posts: 674
Location: Germany, border to Switzerland

PostPosted: Thu Apr 19, 2012 11:38 am    Post subject: Reply with quote

Mal abgesehen davon, dass du aus WPO-Sicht dein Javascript lieber am ende des <body>s laden solltest… ist dein Vorhaben umsetzbar, wenn auch nicht ganz trivial.

Code:
{include file="header"}
{include file="content"}


zum Zeitpunkt wo content ausgeführt wird, ist header schon evaluiert worden. Das heisst das da keine Variablen mehr eingefügt werden können. Was du aber machen kannst, is dein plugin die Werte irgendwohin schreiben lassen und in einem outputfilter vor das </head> packen.
_________________
Twitter
Back to top
View user's profile Send private message Visit poster's website
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