RE: [SMARTY] Section problem
| From: | Jeff Dickens | Date: | Thu, 20 Feb 2003 16:01:00 +0000 |
| Subject: | RE: [SMARTY] Section problem | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-8012@lists.php.net to get a copy of this message | ||
Pardon the duplication, I forgot to reply to the list.
I did this for my menu:
in PHP:
(URL_BASE is a constant...)
$menu = array( "home" =>
array( "url" => URL_BASE,
"title" => "Home"
),
"twisting" =>
array( "url" => URL_BASE . "?page=twisting",
"title" => "Twisting"
),
"bouquets" =>
array( "url" => URL_BASE . "?page=bouquets",
"title" => "Bouquets"
),
"decor" =>
array( "url" => URL_BASE . "?page=decor",
"title" => "Decor"
),
"contact" =>
array( "url" => URL_BASE . "?page=contact",
"title" => "Contact Us"
)
);
In the template:
<table class=sidemenu cellspacing="0" cellpadding="0">
<tr><th><div
class="sectiontitle">Site Menu</div></th></tr>
{foreach item=item from=$menu key=key}
{if $key eq "home"}
<tr>
<td><a class="menutop"
href="{$item.url}">{$item.title}</a></td>
</tr>
{else}
<tr>
<td><a href="{$item.url}">{$item.title}</a></td>
</tr>
{/if}
{/foreach}
</table>
My plan is to extend this to include a third element in each of the inner
associative arrays which would contain the name of an image to use for an
image-based menu.
fwiw, the completed (for now) site is at http://twinkiestwistables.com.
>-----Original Message-----
>From: Tom Sommer [mailto:webmaster@tsn.dk]
>Sent: Thursday, February 20, 2003 8:53 AM
>To: smarty-general@lists.php.net
>Subject: [SMARTY] Section problem
>
>
>hey everyone,
>
>I have this newbie problem with section
>I've got this:
>
>{section name=menu loop=$menu}
>menu = {$menu[menu]}
>{/section}
>
>$menu looks like this:
>array(
> "News" => "index.php",
> "About" => "about.php",
> "Articles" => "articles.php",
> "Desktops" => "desktop.php",
> "Forums" => "forums.php",
> "Links" => "links.php",
> "Contact" => "contact.php"
> );
>
>How do I loop those with section?
>In the documentation it does not state how the array should look
>for section
>to work...
>
>thanks
>--
>Tom Sommer
>www.tsn.dk - www.dreamcoder.dk
>
>
>
>--
>Smarty General Mailing List (http://smarty.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>