Welcome Guest, Not a member yet? Register   Sign In
CMS - parse a gallery from view, from database-stored content?
#3

[eluser]Enorog[/eluser]
Thanks for your ideas, it's close to what I need.

I ended up solving my problem - I used an upgraded parsing library that can call a helper from the view. I created a function in the helper that does all the gallery preparation for me. I wanted this flexibility to avoid too many modules on the page - I want the client to just compose everything in the html editor (FCKeditor).

I think it might be useful for somebody else to see how I've created the helper function.

It goes to a directory on my server, looks for the images, looks for the thumbnails and then creates a nice list (I process this with a jQuery popup script). Everything gets created automatically, the client only needs to write {prepare_gallery(folder_name)} inside his html content.

Here is the source code:

Code:
function prepare_gallery($folder_name)
{

    $result = '<div id="gallery">';
    
    $listing_big = get_filenames('files/images/galleries/' . $folder_name);
    $listing_thumb = get_filenames('files/images/galleries/' . $folder_name . '-thumb');

    $listing_size = sizeof($listing_big);

    for ($i = 0; $i < $listing_size; $i++) {
        
        $listing_big[$i] = 'files/images/galleries/' . $folder_name . '/' . $listing_big[$i];
        $listing_thumb[$i] = 'files/images/galleries/' . $folder_name . '-thumb/' . $listing_thumb[$i];
        
        $size_big[$i] = getimagesize($listing_big[$i]);
        $size_thumb[$i] = getimagesize($listing_thumb[$i]);
        
        $result .= '<div class="gallery_box"> ';
        $result .= '<a class="popup" href="' . base_url() . $listing_big[$i] . '">';
        $result .= '<img class="gallery_border" src="' . base_url() . $listing_thumb[$i] . '" alt="Your_Selector" />';
        $result .= '</a>';
        $result .= '</div> &lt;!-- end gallery_box --&gt;
        ';
    
    }
    
    $result .= '</div> &lt;!-- end gallery --&gt;';
    
    return $result;

}


Messages In This Thread
CMS - parse a gallery from view, from database-stored content? - by El Forum - 09-01-2009, 10:20 AM



Theme © iAndrew 2016 - Forum software by © MyBB