how to use a function inside brackets?

From: Date: Mon, 17 Mar 2003 14:57:54 +0000
Subject: how to use a function inside brackets?
Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-8695@lists.php.net to get a copy of this message
Hi, I don't if this has been already discussed, but I didn't find related material about this... I made a custom function that outputs a random number between two numbers. For example, if I do {random in=5 out=10} it will output 8... what I want to do is display a random image. My images are numbered like that: img1.gif img2.gif img3.gif In HTML I do <img src="img{random in=1 out=3}.gif"> and it works fine. But I am using this in a file I include (I specify the image name): {include file="menu_element.tpl" menu_img="Image.gif" menu_text="Network diagram"} How could I use my random function in that case? I can't do the following: {include file="menu_element.tpl" menu_img="img{random in=1 out=3}.gif" menu_text="Network diagram"} I found a workaround: {random in=1 out=3 outputToVar=true} {include file="menu_element.tpl" menu_img="img$random_number.gif" menu_text="Network diagram"} And in my function, if outputToVar is set to true I assign the result to a var instead of outputting it... My workaround works, but I thinks it kind of sucks... Do you have any suggestion of how I should do that? I really would be great to ba able to use curly brackets inside curly brackets !!! Thanks, Philippe. ========================================================== Ce message et ses pièces jointes (le "message") est destiné à l'usage exclusif de son destinataire. Si vous recevez ce message par erreur, merci d'en aviser immédiatement l'expéditeur et de le détruire ensuite. Le présent message pouvant être altéré à notre insu, Crédit Agricole Indosuez ne peut pas être engagé par son contenu. Tous droits réservés. This message and/or any attachments (the "message") is intended for the sole use of its adressee. If you are not the adressee, please immediately notify the sender and then destroy the message. As this message and/or any attachments may have been altered without our knowledge, its content is not legally binding on Crédit Agricole Indosuez. All rights reserved. ==========================================================

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