RE: [SMARTY] Another array related question

From: Date: Mon, 14 Apr 2003 22:06:53 +0000
Subject: RE: [SMARTY] Another array related question
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-9257@lists.php.net to get a copy of this message
It's a PHP function, you can use a PHP function in an if expression unless you configure Smarty to allow only some specific PHP functions in if statements. If your users can upload/edit templates then you may need to disable this feature to prevent a user from {if system('do some disaster here')}{/if} or similar. If you have templates as controlled as PHP sources then you will be able to use count() and other PHP functions the expression that if evaluates. -----Original Message----- From: Nancy Milligan [mailto:npm@cox.net] Sent: Monday, April 14, 2003 6:50 PM To: luis; smarty-general@lists.php.net Subject: Re: [SMARTY] Another array related question Is count undocumented? I have: Table of Contents count_characters count_paragraphs count_sentences count_words In the docs, but I'm not seeing anything about count. Perhaps I'm missing out on something! Nancy ----- Original Message ----- From: "luis" <luis@fuegolabs.com> To: "'Nancy Milligan'" <npm@cox.net>; <smarty-general@lists.php.net> Sent: Monday, April 14, 2003 1:30 PM Subject: RE: [SMARTY] Another array related question > {if count($foo)>0} > Something if the array has elements > {else} > > {/if} > > Note: If you are looping an array and want a special behaviour if the > array is empty use instead: > > {section name=ix loop=$foo} > code > {sectionelse} > code if empty array > {/section} > > If you want the keys of the array then may I ask what do you want to do > with the keys? :-) Smarty foreach or section loops can be used depending > on what you want to do. > > > > -----Original Message----- > From: Nancy Milligan [mailto:npm@cox.net] > Sent: Monday, April 14, 2003 5:16 PM > To: smarty-general@lists.php.net > Subject: [SMARTY] Another array related question > > Is there anyway in Smarty to find out the number of elements in an > array? Or is there a way to return all the keys of an array as an > array? Or do people usually create some PhP code inside a Smarty > template to handle that? > > Thanks! > > Nancy M. > > > -- > Smarty General Mailing List (http://smarty.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- Smarty General Mailing List (http://smarty.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.smarty.general (#9257) next »