Using Javascript to Call Smarty?
| From: | Sarah Gray | Date: | Wed, 12 May 2004 16:12:03 +0000 |
| Subject: | Using Javascript to Call Smarty? | ||
| Groups: | php.smarty.general | ||
| Request: | Send a blank email to php-smarty-general+get-11382@lists.php.net to get a copy of this message | ||
Hi --
I have to include a smarty template from within another smarty template
based on whether or not a javascript cookie is read (to see if the user
is logged in or not).
All is fine when I read the cookie. However, I tried to
document.write('{include file="template.tpl"}') if the cookie was there,
and it just wrote the line of text -- {include file="template.tpl"} --
on the page but did not execute it (ie, did not actually include the
file).
I included the javascript in {literal} tags -- which may be part of the
problem.
Then I tried leaving the {include file="template.tpl"} block outside of
the literal tags, but then it got included regardless of whether the
cookie was there.
I thought maybe I would use document.write in the included template --
to render the tables: but I have smarty variables in those as well so I
think I would run into the same issue as above.
My question is, is there any way to use Javascript in this way?
Thanks,
s.