Page 1 of 1

output all images from certain folder

Posted: Sun Aug 23, 2009 7:11 am
by grimmus
Hi,

I would like to output all the images from a certain folder into a div so i can fade through them with jQuery

so, for example, if i am in the 'about us' page the function looks in the images/about-us folder and returns all the images. And if i am in a different section it looks in that section folder (i.e. services section looks in images/services folder.)

Is there something that already does this or does someone have some sample code ?

Thanks in advance

Re: output all images from certain folder

Posted: Tue Aug 25, 2009 10:18 am
by mls24
create user defined tag and use it in the template.

here is my code for doing this

$files = glob("uploads/images/".$params['id']."/*.*", GLOB_BRACE);

print '';
$folder = $params['id'].'/';
$i=1;
foreach($files as $file)
{
        if(!preg_match('/thumb/',$file))
        {           
            $image = explode('.',$files[$i]);
            $im = explode($folder,$image[0]);
            $thumb = explode($folder,$file);
            $path =  $thumb[0].$folder.'/thumb_'.$thumb[1];

            print"";
                  print"";
                  print" ";
                  print " ";
            print"";           
        }       
}

where $params['id'] is the get or post parameter from page visited

{userdefinedtagname  id=$smarty.get.page}

Re: output all images from certain folder

Posted: Wed Aug 26, 2009 9:37 am
by grimmus
Thanks alot, that worked great.

Just one other question.

How could i get the alias of the parent page ?

I can get the current alias like : {$page_alias} so i am hoping there is a simple way like this to get the parent alias

Thanks

Re: output all images from certain folder

Posted: Wed Aug 26, 2009 1:33 pm
by mls24
you can try this one

{get_root_page_alias assign="root_page_alias"}

you can use in your template or in udt as $root_page_alias.

cheers