By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,347 Members | 1,390 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,347 IT Pros & Developers. It's quick & easy.

2 questions about smarty

P: n/a
1. How could concatenate two values into a string in the template?

{section name=j start=0 loop=10 step=1}
{section name=k start=0 loop=10 step=1}
{assign var=xx value=concat($smarty.section.j,$smarty.section.k)}
{xx}
{/seection}
{/section}

2. How could I address/use associative array in the template? I could do
it with numbers, but it will be more self-documentating if I could use
assoc. array....

--
iTech Consulting Services Limited
Expert of ePOS solutions
Website: http://www.itech.com.hk (IE only)
Tel: (852)2325 3883 Fax: (852)2325 8288
Apr 23 '07 #1
Share this Question
Share on Google+
7 Replies


P: n/a
1. How could concatenate two values into a string in the template?
>
{section name=j start=0 loop=10 step=1}
{section name=k start=0 loop=10 step=1}
{assign var=xx value=concat($smarty.section.j,$smarty.section.k)}
I gave up and use PHP codes to do it.

<?php $combined="COL{$part1}ROW{$part2}"; ?>
<input type="textbox" id="txtQty<?php echo $combined; ?>">
{xx}
{/seection}
{/section}
2. How could I address/use associative array in the template? I could do
it with numbers, but it will be more self-documentating if I could use
assoc. array....
It's {$array[i][j].attribute}. But what if the index is not in the end?
Will {$array[i].attribute.[j]} work?

--
iTech Consulting Services Limited
Expert of ePOS solutions
Website: http://www.itech.com.hk (IE only)
Tel: (852)2325 3883 Fax: (852)2325 8288
Apr 23 '07 #2

P: n/a
Man-wai Chang wrote:
{section name=j start=0 loop=10 step=1}
{section name=k start=0 loop=10 step=1}
{assign var=xx value=concat($smarty.section.j,$smarty.section.k)}
{xx}
{/seection}
{/section}
Yes, using Smarty is so much easier than using a full blown scripting
language. ;-)

--
Toby A Inkster BSc (Hons) ARCS
http://tobyinkster.co.uk/
Geek of ~ HTML/SQL/Perl/PHP/Python*/Apache/Linux

* = I'm getting there!
Apr 23 '07 #3

P: n/a
On Apr 23, 2:28 pm, Man-wai Chang <toylet.toy...@gmail.comwrote:
1. How could concatenate two values into a string in the template?

{section name=j start=0 loop=10 step=1}
{section name=k start=0 loop=10 step=1}
{assign var=xx value=concat($smarty.section.j,$smarty.section.k)}
{xx}
{/seection}
{/section}
You can concatenate by following way
{assign var=xx value=$smarty.section.j|cat:$smarty.section.k}

2. How could I address/use associative array in the template? I could do
it with numbers, but it will be more self-documentating if I could use
assoc. array....
Read smarty manual for this .... You will get better idea from there
itself. :)
iTech Consulting Services Limited
Expert of ePOS solutions
Website:http://www.itech.com.hk(IE only)
Tel: (852)2325 3883 Fax: (852)2325 8288

Apr 23 '07 #4

P: n/a
You can concatenate by following way
{assign var=xx value=$smarty.section.j|cat:$smarty.section.k}
let me try....
Read smarty manual for this .... You will get better idea from there
itself. :)
is $array[i][j].attribute the same as $array.i.j.attribute?

--
iTech Consulting Services Limited
Expert of ePOS solutions
Website: http://www.itech.com.hk (IE only)
Tel: (852)2325 3883 Fax: (852)2325 8288
Apr 24 '07 #5

P: n/a
>
Yes, using Smarty is so much easier than using a full blown scripting
language. ;-)
I am looking for a code generator, to be exact. If you used Foxpro/DOS
or Foxpro/Windows before, you would know what I meant. LAMP is a long,
long road from Foxpro in terms of speed and ease of development.

--
iTech Consulting Services Limited
Expert of ePOS solutions
Website: http://www.itech.com.hk (IE only)
Tel: (852)2325 3883 Fax: (852)2325 8288
Apr 24 '07 #6

P: n/a
You can concatenate by following way
{assign var=xx value=$smarty.section.j|cat:$smarty.section.k}
{assign var=xx value=$smarty.section.j|cat:cat:$smarty.section.k}

Um... I got "Array" as output.

And how could I show the version of smarty?

--
iTech Consulting Services Limited
Expert of ePOS solutions
Website: http://www.itech.com.hk (IE only)
Tel: (852)2325 3883 Fax: (852)2325 8288
Apr 24 '07 #7

P: n/a
is $array[i][j].attribute the same as $array.i.j.attribute?

ok... figured it out.

$array[$ileft].attribute is the same as $array.$ileft.attribute!

In short, the square brackets could be replaced by a dot.

--
iTech Consulting Services Limited
Expert of ePOS solutions
Website: http://www.itech.com.hk (IE only)
Tel: (852)2325 3883 Fax: (852)2325 8288
Apr 24 '07 #8

This discussion thread is closed

Replies have been disabled for this discussion.