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

Cycle frustration

 
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 -> General
View previous topic :: View next topic  
Author Message
miah
Smarty n00b


Joined: 20 Apr 2003
Posts: 2
Location: Arvada, CO

PostPosted: Sun Apr 20, 2003 2:15 am    Post subject: Cycle frustration Reply with quote

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 Question
Back to top
View user's profile Send private message Visit poster's website AIM Address
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Sun Apr 20, 2003 12:51 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
miah
Smarty n00b


Joined: 20 Apr 2003
Posts: 2
Location: Arvada, CO

PostPosted: Sun Apr 20, 2003 2:18 pm    Post subject: Excellent! Reply with quote

That worked great, thanks!
Back to top
View user's profile Send private message Visit poster's website AIM Address
shan
Smarty n00b


Joined: 19 Apr 2003
Posts: 4
Location: UK

PostPosted: Thu May 29, 2003 1:16 pm    Post subject: Cycle using background image Reply with quote

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
View user's profile Send private message
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Thu May 29, 2003 2:20 pm    Post subject: Reply with quote

@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
View user's profile Send private message Send e-mail Visit poster's website
shan
Smarty n00b


Joined: 19 Apr 2003
Posts: 4
Location: UK

PostPosted: Thu May 29, 2003 3:53 pm    Post subject: Reply with quote

Idea

spot on, many thanks for your help
Back to top
View user's profile Send private message
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 -> General 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