output all images from certain folder

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
grimmus
Forum Members
Forum Members
Posts: 28
Joined: Sun Jan 11, 2009 7:17 am

output all images from certain folder

Post 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
mls24
Forum Members
Forum Members
Posts: 11
Joined: Fri Jul 17, 2009 5:35 am

Re: output all images from certain folder

Post 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}
grimmus
Forum Members
Forum Members
Posts: 28
Joined: Sun Jan 11, 2009 7:17 am

Re: output all images from certain folder

Post 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
mls24
Forum Members
Forum Members
Posts: 11
Joined: Fri Jul 17, 2009 5:35 am

Re: output all images from certain folder

Post 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
Post Reply

Return to “Modules/Add-Ons”