Re: [SMARTY] Dynamic color
| From: | sweatjejm at mchsi dot com | Date: | Tue, 11 Feb 2003 14:26:21 +0000 |
| Subject: | Re: [SMARTY] Dynamic color | ||
| Groups: | php.smarty.general | ||
| Request: | Send a blank email to php-smarty-general+get-7639@lists.php.net to get a copy of this message | ||
Hi Erich,
I might do something like (untested code):
$smarty->assign(array(
'page_titles' => array('page1', 'page2', 'page3',
'page4')
,'cur_page' => 'page2'
));
$smarty->display('page2.tpl');
and in the template:
{section name=p loop=$page_titles}
<td style="background-color: {if $page_titles[p] eq $cur_page}rgb(0,155,155)
{else}rgb(0,0,255){/if}"> $page_titles[p] </td>
{/section}
Jason
> Hi everyone,
>
> I am new to PHP and Smarty, but here is what I want to do. Basically, I have a
> bunch of pages which all contain the same navigation menu (tables and links,
> nothing really fancy). I want to migrate this to a template, so that I only
> have to modify it once.
>
> No problem, that all works fine. However, what I really want to do is make the
> background color of the <td> for the the current visible page be a different
> color than the rest of the cells on the menu. I am guessing I can do this with
> <td bgcolor={$bgcolor}><a href=#>Link 1</a></td>
>
> What I don't know is where the logic should go to figure out which page is
> currently visible. Should this come from the PHP script, passing a variable to
> the smarty template
> $smarty->assign($bgcolor)
>
> or should this logic be right in the template? Has anyone done something like
> this, and can you point me in the right direction?
>
> Thanks!
>
> -Erich-
>