You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by warrengb <wa...@swebtec.com> on 2006/12/04 11:30:49 UTC
Creating an array of images
Hi I'm pretty new to the velocity side of things so any help would be
appreciated.
I'm trying to create an array of 4 images. My homepage will display a new
image everytime the page is refreshed. I know how to do this in php or
javascript but the problem is that I need the images to be controlled by the
web author in our cms system without having to edit the code hence I need to
do this in velocity.
This is what the php code would look like but I need help doing the same
thing but in velocity.
$input = array("image1.jpg",
"image2.jpg",
"image3.jpg",
"image4.jpg",
"image5.jpg");
$random = array_rand($input, 1);
echo ' '.$random.' ';;
?>
thanks in advance for the help.
W
--
View this message in context: http://www.nabble.com/Creating-an-array-of-images-tf2750362.html#a7673614
Sent from the Velocity - Dev mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org
Re: Creating an array of images
Posted by Jason Pettiss <ja...@TheCatalis.com>.
A more appropriate place for this question would be the user list?
In PHP you do everything on your page, including wiping your own butt.
Velocity is just a template language so making the array and picking the
random index in Java would definitely avoid the need to ask the
question. If you really want to do everything on the page, you'll have
to write a method to give you a random index.
--jason
warrengb wrote:
> Hi I'm pretty new to the velocity side of things so any help would be
> appreciated.
>
> I'm trying to create an array of 4 images. My homepage will display a new
> image everytime the page is refreshed. I know how to do this in php or
> javascript but the problem is that I need the images to be controlled by the
> web author in our cms system without having to edit the code hence I need to
> do this in velocity.
>
> This is what the php code would look like but I need help doing the same
> thing but in velocity.
>
> $input = array("image1.jpg",
> "image2.jpg",
> "image3.jpg",
> "image4.jpg",
> "image5.jpg");
>
> $random = array_rand($input, 1);
>
> echo ' '.$random.' ';;
> ?>
>
> thanks in advance for the help.
>
> W
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org