472,980 Members | 2,068 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,980 software developers and data experts.

multidimensional arrays passed to Smarty?

Does Smarty support assigning multidimensional arrays? I've tried to get
it working, but just can't get it.

can someone help me?
this is what I have in my php file:

$side_bar =
array('link' => array( 'index.php',
'estate.php',
'text' => array( 'Home',
'Real Estate')));
$smarty->assign ("side_bar", $side_bar);

then in my template file I have this:

{section name=i loop=$side_bar}
<tr><td width="19"><img src="images/td_background_left.gif" width="19"
height="22" alt="" border="0"></td>
<td align="left" valign="center" height="22" width="118"
background="images/td_background_right.gif">
<p><span style="font-family: Arial; color:black; font-size: 8pt;">
{if $side_bar.link.i neq ""}
<a href= {$side_bar.link.i} style="text-decoration:none; color:black;">
<b>& {$side_bar.text.i}</b></a></span></p></td></tr>
{else}
<a><b>&{$side_bar.text.i}</b></a></span></p></td></tr>
{/if}
{/section}

with this code, only one row is produced in the table. I guess it's
because $side_bar only has two values which have more values beneath
them. How can I create a side bar that will have the link and then text
that I store in the array? Does it work to have an Associative array
mixed with an Indexed array, and then display the indexed array the way
I tried?

Obviously it does not work like this. I'm fairly new to PHP and Smarty,
so if anyone has suggestions on how I can get this done, please tell me.

Thanks,
Mark
Jul 17 '05 #1
2 13970
In article <44******************************@news.teranews.co m>,
Mark <do***************@hotmail.com> wrote:
Does Smarty support assigning multidimensional arrays? I've tried to get
it working, but just can't get it.


Yes. I use them in {foreach} loops, like this:

{foreach from=$multi_dimensional_array item=array}
<tr><td>{$array.value1}</td><td>{$array.value2}</td></tr>
{/foreach}

JP

--
Sorry, <de*****@cauce.org> is een "spam trap".
E-mail adres is <jpk"at"akamail.com>, waarbij "at" = @.
Jul 17 '05 #2
Jan Pieter Kunst wrote:
In article <44******************************@news.teranews.co m>,
Mark <do***************@hotmail.com> wrote:

Does Smarty support assigning multidimensional arrays? I've tried to get
it working, but just can't get it.

Yes. I use them in {foreach} loops, like this:

{foreach from=$multi_dimensional_array item=array}
<tr><td>{$array.value1}</td><td>{$array.value2}</td></tr>
{/foreach}

JP


Thank you, I got it to work now.
Jul 17 '05 #3

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

Similar topics

5
by: Golf Nut | last post by:
I am finding that altering and affecting values in elements in multidimensional arrays is a huge pain in the ass. I cannot seem to find a consistent way to assign values to arrays. Foreach would...
2
by: shane | last post by:
Ive searched a fair bit for the answer, but nothing has come up that matches what i want to do. I'm having an issue with passing and assigning pointers to multidimensional arrays. The code: ...
2
by: Terry | last post by:
Hi, can someone plz tell me how multidimensional arrays (like a 2-D array) are stored in memory? Are they like single dimensional arrays? Stored sequentially in one "row", so to say? Thanks ...
9
by: Charles Banas | last post by:
i've got an interesting peice of code i'm maintaining, and i'd like to get some opinions and comments on it, hopefully so i can gain some sort of insight as to why this works. at the top of the...
3
by: Claire | last post by:
I have a multidimensional array defined as private double myArray = new double; The first column of the array contains X values, the other contains Y values I have a charting function defined as...
3
by: Ravi Singh (UCSD) | last post by:
Hello all I am trying to use jagged and multi-dimensional arrays in C++. In C# these work fine // for jagged arrays string jaggedArray = new string ; //for multidimensional arrays string...
21
by: utab | last post by:
Hi there, Is there a way to convert a double value to a string. I know that there is fcvt() but I think this function is not a part of the standard library. I want sth from the standard if...
10
by: | last post by:
I'm fairly new to ASP and must admit its proving a lot more unnecessarily complicated than the other languages I know. I feel this is because there aren't many good official resources out there to...
9
by: Slain | last post by:
I need to convert a an array to a multidimensional one. Since I need to wrok with existing code, I need to modify a declaration which looks like this In the .h file int *x; in a initialize...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.