I am working on a website that has images displayed on each page. The images are page related - So www.example.com/elephants
should display only images of elephants.
I thought I could simply solve this by creating a image directory named "Elephants" and add $ThemeDir/images/$URLSegment/image5.jpg to page.ss. This works fine, but it does not work when you have only 3 images for another directory. In that case 5 thumbs will displayed when you only have 3 images in the directory.
So now I was thinking of using PHP using the following code:
// Open a known directory, and proceed to read its contents
$files = glob("images/icons/*.*");
for ($i=1; $i<count($files); $i++)
$num = $files[$i];
echo '<a href="$ThemeDir/images/photos/$URLSegment/image5.jpg" rel="prettyPhoto[pp_gal]" title="$Title"><img src="'.$num.'" alt="random image" border="0" width="48" height="48" alt="Elephants"></a>'." ";
This shows exactly all the images of a certain directory. But somehow I cannot use the dynamic Silverstripe values like $ThemeDir, $URLSegment etc. What am I missing? This might be a dumb question, but I am not really into PHP and I really trying hard to understand it, so if one of you could answer I would be very grateful.
Or if you guys know another workaround that would also be great.
(see current project here: http://www.wezzbite.nl/Silverstripe/zwangerschapsyoga/) images right side.