You are here: Re: [SMARTY] simple loops? « Smarty Templates Posts « IT news, forums, messages
Re: [SMARTY] simple loops?

Posted by Dc on 05/12/05 04:57

some questions on smarty syntax...

---- escaping
is there an escape code? i need to get some curly brackets in my returned
text... eg if {$name} is a variable holding "fred"

I need {=fred}
but
{={$name}}

gives me smarty errors.
\{= .. also...

---- backticks
What are the backticks for in smarty? i noticed

{assign var='px' value="`$smarty.section.menu.index`*5" }

if the section index is 3, this returns "3*5" as a string...rather than
"15"
but removing the backticks gives a calculation.

------- section index
also, a question about using "section" for simple counter loops...
this example from the docs:

{section name=customer loop=$custid}
id: {$custid[customer]}<br>
name: {$name[customer]}<br>
address: {$address[customer]}<br>
<p>

seems to use [customer] as an integer/array index.
yet {$customer} returns "Array" as a type. To get a value to use I have to
do {$smarty.section.customer.index}
I dont quite follow why it works in one case but not another...


Thanks!

/dc

On Mon, 04 Apr 2005 17:46:37 +0900, messju mohr
<messju@lammfellpuschen.de> wrote:

> On Mon, Apr 04, 2005 at 03:18:25PM +0900, D_C wrote:
>> hiya -
>>
>> is there a way to do a simple iteration loop in smarty, if I dont have
>> an object to iterate over? eg if i want to put in X lines of
>> spacing...
>>
>> {foreach var="i" start="0" end="10" step="1" }
>> ... do something
>
> you can use sections for that:
> {section name=i loop=10} ... {/section}
> (see: http://smarty.php.net/manual/en/language.function.section.php)
>
>> or can i call a PHP function inline to return text?
>
> yes, with a modifier:
> {" ... "|str_repeat:10}
> (see: http://smarty.php.net/manual/en/language.modifiers.php)
>
> greetings
> messju
>
>> tx!



--
_______________________________________________
David "DC" Collier
mobile business creator |モバイル・ビジネス・クリエーター
dc@pikkle.com
skype: callto://d3ntaku
http://www.pikkle.com
new number! >>>>
+81 (0)80 6521 9559

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация