|
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 |
miah Smarty n00b
Joined: 20 Apr 2003 Posts: 2 Location: Arvada, CO
|
Posted: Sun Apr 20, 2003 2:15 am Post subject: Cycle frustration |
|
|
Ok, I have a cycle set up like this:
Code: | {cycle values="#000000,#FFFFFF"} |
And what I'd like to do is set some default variables in a config file like this:
Code: | bgcolor = #FFFFFF
sidecolor = #000000
|
Now, I set this in the config file but I cannot for the life of me figure out how to get the cycle command to cycle on variables out of config files.
I was thinking something like this would work, but it doesn't:
Code: | {cycle values="{#sidecolor#},{#bgcolor#}"} |
What is the right way to do this and get it to cycle colors based on configuration files? This is really important to setting up themes on a site.
JStanley |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Sun Apr 20, 2003 12:51 pm Post subject: |
|
|
it's easiest to setup the list in config-file:
cycle_colors="#000000,#FFFFFF"
and then just do:
{cycle values=#cycle_colors#}
if you really have the need to have two distinct colors in your config-file then do someting like:
{cycle values="%s,%s"|sprintf:#col1#:#col2#} or
{cycle values=#col1#|cat:","|cat:#col2#}
but it is ugly to do this in the template IMHO. |
|
Back to top |
|
miah Smarty n00b
Joined: 20 Apr 2003 Posts: 2 Location: Arvada, CO
|
Posted: Sun Apr 20, 2003 2:18 pm Post subject: Excellent! |
|
|
That worked great, thanks! |
|
Back to top |
|
shan Smarty n00b
Joined: 19 Apr 2003 Posts: 4 Location: UK
|
Posted: Thu May 29, 2003 1:16 pm Post subject: Cycle using background image |
|
|
Hi all,
Im trying to use a background image to cycle behind menu items in a loop.
Heres what Ive tried
Code: | <tr background="
{cycle values=
{$ImagesDir}/template/menu_bg_1.gif,{$ImagesDir}/template/menu_bg_2.gif
}
"> |
the error that i get is ..
Quote: | Parse error: parse error, unexpected '"', expecting '}' in c:\program files\apache group\apache\htdocs\angel\templates_c\%%-12\%%-1253885908\categories.tpl.php on line 48 |
Im guessing its to do with the {$ImagesDir} bit, any ideas |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Thu May 29, 2003 2:20 pm Post subject: |
|
|
@shan:
your assumption is correct: you cannot nest delimiters in smarty. your error-message tells me, that you use an older version of smarty, right? then your syntax would be like string-concatenation in php then:
<tr background="{cycle values=".$ImagesDir."/template/menu_bg_1.gif,".$ImagesDir."/template/menu_bg_2.gif"}">
since smarty-2.5.0 you can simply write:
<tr background="{cycle values="$ImagesDir/template/menu_bg_1.gif,$ImagesDir/template/menu_bg_2.gif"}"> |
|
Back to top |
|
shan Smarty n00b
Joined: 19 Apr 2003 Posts: 4 Location: UK
|
Posted: Thu May 29, 2003 3:53 pm Post subject: |
|
|
spot on, many thanks for your help |
|
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
|