473,788 Members | 2,856 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Smarty Problem

Hello

I have a Smarty(.php.net ) Question.

I want to create a Navigation with a Smarty Template.

How can I display an Array recursively?
Do I have to write a Plugin?
Exmp.
Array
(
[0] => Array
(
[Text] => "Item 1"
[Childs] => Array
(
[0] => Array
(
[Text] => "Item 1.1"
[Childs] => Array
(
[0] => Array
(
[Text] => "Item 1.1.1"
)
[1] => Array
(
[Text] => "Item 1.1.2"
)
)
)
[1] => Array
(
[Text] => "Item 1.2"
[Childs] => Array
(
[0] => Array
(
[Text] => "Item 1.2.1"
)
[1] => Array
(
[Text] => "Item 1.2.2"
)
)
)
)
)
[1] => Array
(
[Text] => "Item 2"
[Childs] => Array
(
[0] => Array
(
[Text] => "Item 2.1"
)
)
)
)

Something like this
-------------------

{navigation item=item from=$array}
<td>{$item.text }</td>
{/navigation}
Best Regards

Jim
Jul 17 '05 #1
1 2308
On Tue, 14 Sep 2004 14:45:49 +0200, Jim Red <ji******@hotma il.com>
wrote:
Hello

I have a Smarty(.php.net ) Question.

I want to create a Navigation with a Smarty Template.

How can I display an Array recursively?
Do I have to write a Plugin?
Exmp.
Array
(
[0] => Array
(
[Text] => "Item 1"
[Childs] => Array
(
[0] => Array
(
[Text] => "Item 1.1"
[Childs] => Array
(
[0] => Array
(
[Text] => "Item 1.1.1"
)
[1] => Array
(
[Text] => "Item 1.1.2"
)
)
)
[1] => Array
(
[Text] => "Item 1.2"
[Childs] => Array
(
[0] => Array
(
[Text] => "Item 1.2.1"
)
[1] => Array
(
[Text] => "Item 1.2.2"
)
)
)
)
)
[1] => Array
(
[Text] => "Item 2"
[Childs] => Array
(
[0] => Array
(
[Text] => "Item 2.1"
)
)
)
)

Something like this
-------------------

{navigation item=item from=$array}
<td>{$item.text }</td>
{/navigation}
Best Regards

Jim

There's {section} and {foreach} you could try.. unless you specifically
wanted to write a {navigation} plugin.

You might also need to make use of {assign} to assign some arrays
temporarily through the stages, inwhich case, a plugin maybe a better
solution as per your specific requirements.

You might also get better / more concise opinions / solutions posting on
the forum at <http://smarty.php.net/>. Some helpful people there too
"specifical ly" involved in Smarty =)

Regards,

Ian

--
Ian.H
digiServ Network
London, UK
http://digiserv.net/
Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2917
by: Daan | last post by:
Hello all, I'm having a little problem with Smarty. Getting it to work in a simple case went fine, but now I have the following situation: / /smarty /templates template.tpl /templates_c
1
2314
by: Richard | last post by:
I need help. I have a smarty based program that I am modifying. I have a smarty template file that consists of smarty and HTML. I need to integrate some PHP database calls into it. My problem is I cannot figure out how to pass value between smarty and PHP. Going from php to smarty I've tried this: {php} $smarty = new Smarty; $smarty->assign("x", 100);
2
2610
by: M | last post by:
Hi Folks, I am trying to install Smarty using PHP 5 on a Windows XP PC using IIS v6 The following PHP File: <!doctype html public "-//W3C//DTD HTML 4.0 //EN"> <html> <head>
0
1591
by: Matt | last post by:
geez, i've done this a million times, you'd think i could get it right. uploading to production server for a new site, and part of the head.inc that starts everything up looks like this: echo SMARTY_DIR."Smarty.class.php<br>"; require_once(SMARTY_DIR."Smarty.class.php"); if (substr(phpversion(),0,1) == "4") { $smarty = new Smarty;
0
1609
by: Conrad | last post by:
Hi, I'm very new to Smarty Template Engine and I'm using PHP 5.0.4 on the Windows XP Professional platform and I have the following question: When I change the 7th line of the script to use a new name and refresh the browser, it maintains the old value instead of updating to the new value. Both index.php and SmartySetup.class.php appear below: index.php:
2
2071
by: Gene | last post by:
i'm newcomer in using smarty and i have problem like this: i want to have one template file (e.g. index.tpl) in this file section which use variable {$content}. and two files *.php which are using the same template index.tpl and only change the content. for example: /*index.php*/ $smarty = new MySmarty(); $smarty->assign('content','INDEX');
0
2159
by: grezlik | last post by:
Hi! I have major problems with cakephp & smarty, (cake ver is 1.2 and smarty 2.6.18 ) there is a code (from cake/libs/view/view.php class SmartyView { .. .. ..
7
2693
by: diane100 | last post by:
Hi I am new to PHP and Smarty (I know only very basic things) and I need help with a warning message I get when I call a page in a browser. I purchased some software from a company who are no longer replying to my messages for help so I have decided to try and fix the many problems myself. I am receiving the following messages when loading any of my pages and some pages are not even showing at all. Warning:...
6
3104
by: K. | last post by:
Hello! I have a problem with using php on smarty web page I would like to use a php code from this web page: http://www.money.pl/webmaster/# i.e.. <?php readfile ('http://cw.money.pl/wiadomosci_banki.html', true) ?>
1
2624
by: ajaymohank | last post by:
hello friends.......... i am new to smarty. can anyone please tell me how to get the value from a dynamically generated checkbox using smarty. this is the code i used... here i am generating 10 checkbox. but i am not getting the value when each checkbox is checked. the value is coming from the array $profservices. how can i get the value from each checkbox when they are selected. also i have a "Select all" checkbox generated. how will i write...
0
9656
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9498
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10373
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10177
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10118
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9969
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7519
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5538
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2897
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.