1
mschmid
array[][] and xoops template (smarty)
  • 2004/7/12 19:44

  • mschmid

  • Just popping in

  • Posts: 28

  • Since: 2002/9/19


I wanna use a 2 dimensional array. Fill it in php and print
it out in XOOPS template (smarty).

In php:
-------
$ssr[0][0] = "foobar";
echo $ssr[0][0];
This prints: foobar

if I wanna have this foobar in the XOOPS template, it does
not work?
In the template:
----------------
TestFooBar: <{$ssr[0][0]}><br>

even if I add in php $xoopsTpl->assign('ssr',$ssr[0][0]);

If I have normal variables then it works.

Any input or hint will help
many thx
Markus

2
Mithrandir
Re: array[][] and xoops template (smarty)

if you do the latter, it will be assinged as $ssr - not $ssr[0][0]

But basically, Smarty separates dimensions in an array with a period, so if you do

$xoopsTpl->assign('ssr', $ssr);

you should be able to access the [0][0] element with

<{$ssr.0.0}>

3
intel352
Re: array[][] and xoops template (smarty)
  • 2004/7/12 20:12

  • intel352

  • Module Developer

  • Posts: 824

  • Since: 2003/11/23


if you want to see a smarty example (by me, whoop-de-doo) of an array in action, check this thread:

https://xoops.org/modules/newbb/viewtopic.php?forum=17&topic_id=19614




that's some code i wrote after reading other's examples online, might be useful to help explain array usage

4
mschmid
Re: array[][] and xoops template (smarty)
  • 2004/7/12 20:30

  • mschmid

  • Just popping in

  • Posts: 28

  • Since: 2002/9/19


Hey MANY thx it works with your help )

Below what I did for completation if it helps some one else:

PHP:
----
for ($j = 1; $j <= $countToDisplay; $j++) {
$ssr[$j][0] = "fooBar0";
$ssr[$j][1] = "fooBar1";
.......
}

// it look that the assign does the full handover of the
// hole $ssr array whatever it is.

$xoopsTpl->assign('ssr',$ssr);

Themplate:
----------
<{section name=i loop=$itemCountToDisplay}>
TestFooBar0: <{$ssr[i].0}><br>
TestFooBar1: <{$ssr[i].1}><br>
<{/section}>

5
intel352
Re: array[][] and xoops template (smarty)
  • 2004/7/12 20:47

  • intel352

  • Module Developer

  • Posts: 824

  • Since: 2003/11/23


excellent, glad to hear it

Login

Who's Online

216 user(s) are online (122 user(s) are browsing Support Forums)


Members: 0


Guests: 216


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: May 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits