|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
wwarby Smarty n00b
Joined: 06 Aug 2006 Posts: 1
|
Posted: Sun Aug 06, 2006 8:23 am Post subject: Pass smarty variable as argument to function within {php} |
|
|
I am familiar with PHP but completely new to smarty. I am creating a theme for Menalto Gallery2, and struggling with something hopefully quite simple. The end game is that I want to display a PNG image within my template and apply a CSS style to it only when I detect IE 5.5 or 6.0 as the browser - I plan on doing this using a PHP function which checks the browser version and outputs the <img> tag, taking the URL of the image as an argument, and the problem I am having is in the passing of that URL to the function because part of it comes from a smarty variable.
If I insert this in my .tpl file:
Theme Base: {$theme.themeUrl}
I get this output:
Theme Base: themes/theme_name
However, if I do this:
{php}echo(pngImage({$theme.themeUrl}.'/images/myimage.png'));{/php}
The {$theme.themeUrl} part doesn't work, presumably because it's inside a {php} block. I've tried at least 10 different ways of writing this expression and spent all morning searching these forums and the documentation - trouble is, I don't really know what I'm looking for.
Would be extremely grateful for any help here.
Incidentally, another way I have seen the base path inserted in Gallery2 templates is like so: {g->theme url="images/myimage.png"}. Don't know if that way may offer a better solution. Unfortunately I don't understand smarty syntax at all.
-William |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Mon Aug 07, 2006 8:04 am Post subject: |
|
|
You should avoid {php} and better use a function plugin in the template.
(If you don't believe me you may want to use $this->get_template_vars()) |
|
Back to top |
|
|
|
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
|