View previous topic :: View next topic |
Author |
Message |
stiwan Smarty n00b
Joined: 09 Feb 2004 Posts: 4 Location: Erftstadt, Germany
|
Posted: Mon Feb 09, 2004 9:20 pm Post subject: Session ID via Link .. |
|
|
Hi!
I programmed a session class and i want to use it with smarty.
Therefour i want Smarty to replace all the Links with this mask: <a href="linktarget.php{$sid}">foo</a> so that {$sid} is behind every link target.
i don't want to replace all links myself because it's a larger system (cms) and it would be to complicated.
if anybody knows it, let me know, thnx a lot !
stefan |
|
Back to top |
|
stiwan Smarty n00b
Joined: 09 Feb 2004 Posts: 4 Location: Erftstadt, Germany
|
Posted: Tue Feb 10, 2004 11:38 am Post subject: |
|
|
and further i want to know:
what do i have to do to edit my templates via TEXTAREA ? the content of the file gets saved in a var via fread and then? when there is an </textarea> tag in the template file, i can't edit it.. and & bnsp ; is replaced by a space..
thx! |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Tue Feb 10, 2004 11:58 am Post subject: |
|
|
the simplest way to get the SID appended to each url is to use php's session.use_trans_sid-feature.
if you want to do it in smarty, you could write a prefilter that looks for <a href=".."> in the sourcecode and appends it there.
i tend to have a {href}-custom-function in my projects (with a different implementation depending on the project). this gives me an abstraction of internal links in templates like: '<a href="{href path="/news"}">...' .
the function knows best if this is "news.php" or "index.php?page=news" or "/news/" or whatever and returns the correspendonding url. so if the structure changes (or moves to another directory another server or whatever), i don't have to touch each and every template (and would forget half of all links) to reflect the changes.
so in my case i would have to add a single line to my smarty_function_href() to append the $sid-template-var to the returned url, ét voilà: all urls have it appended.
i have made good experience with my {href} function, maybe this is a useful approach for others, too. |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Tue Feb 10, 2004 12:02 pm Post subject: |
|
|
stiwan wrote: | what do i have to do to edit my templates via TEXTAREA ? the content of the file gets saved in a var via fread and then? when there is an </textarea> tag in the template file, i can't edit it.. and & bnsp ; is replaced by a space.. |
hmm, you should have taken time to create a new topic on this one, instead of hitchhiking your own $sid-topic. i think "Session ID via Link .." makes your question hard to find for all the textarea-pros out there
anyway, you have to quote the contents correctly to make them work in a textarea:
<textarea>{$tpl_source|escape}</textarea>
(this is also true for <input> and others). |
|
Back to top |
|
stiwan Smarty n00b
Joined: 09 Feb 2004 Posts: 4 Location: Erftstadt, Germany
|
Posted: Tue Feb 10, 2004 12:25 pm Post subject: |
|
|
ok textarea prob is not THAT important ..
but i didn't understand what you meant how to append ? i don't want to change the templates and i don't want to use smarty code there, only variables and html sourcecode..
can you / somebody post what i'd have to change in which function etc. ? sorry i'm a newbie with customizing smarty :/ |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Tue Feb 10, 2004 12:49 pm Post subject: |
|
|
???
I think I don't understand your problem. Are your templates smarty templates? |
|
Back to top |
|
stiwan Smarty n00b
Joined: 09 Feb 2004 Posts: 4 Location: Erftstadt, Germany
|
Posted: Tue Feb 10, 2004 4:27 pm Post subject: |
|
|
yes.
these are simple templates that are compiled by smarty and put out..
i think you didn't think of the fact that i made my own session class.. |
|
Back to top |
|
|