ZenphotoCMS Forum
Loading comments and exif data dynamically in jQuery - Printable Version

+- ZenphotoCMS Forum (https://forum.zenphoto.org)
+-- Forum: Support (https://forum.zenphoto.org/forum-1.html)
+--- Forum: Themes (https://forum.zenphoto.org/forum-5.html)
+--- Thread: Loading comments and exif data dynamically in jQuery (/thread-9393.html)



Loading comments and exif data dynamically in jQuery - fuz3d - 16-12-2011

This is my first attempt to make a Zenphoto theme. Actually, not 'make' a theme, but convert a jQuery gallery [http://tympanus.net/codrops/2010/05/14/sliding-panel-photo-wall-gallery-with-jquery/] to Zenphoto theme.

The thumbnails of the pictures are loaded, when the user clicks on the thumbnail, the image enlarges dynamically [jQuery] i.e. without going to the image page loading the image in the album page itself. I have been successful converting that jQuery gallery [as is] to a basic Zenphoto theme.

The issue arises when I want to show comments and meta data for the image clicked.

I am not sure [b]what[/b] parameters to pass via jQuery to [b]which[/b][b] file to get the comments and exif data loaded dynamically.

What I have done till now is:

-Get the image parameter via the id of the image which I have set on album.php

`

`
-Make a PHP file with the following code ---- anotherfile.php:

`

But this throws an error understandably:Call to a member function get() on a non-object`

What parameter do I have to pass to getMetaDataImage function or printImageMetaData function to load the metadata dynamically for the image clicked? And similarly to the comment function?[/b]




Loading comments and exif data dynamically in jQuery - acrylian - 16-12-2011

Please see:
http://www.zenphoto.org/news/category/theming-templating
and especially:
http://www.zenphoto.org/news/zenphotos-object-model-framework

In short you arer outside the context and have to pass the image name and its albums name (you can have images of the same name in several albums, you know?) and then create a new image object on the page.




Loading comments and exif data dynamically in jQuery - fuz3d - 16-12-2011

Thanks for your quick reply.

After reading those links, this is what I came up with:

anotherfile.php

`

This gives the error:Class 'Gallery' not found`

Am I missing something?




Loading comments and exif data dynamically in jQuery - sbillard - 16-12-2011

Unless your above code is situated in the zp-core folder the require_once("functions.php"); will not load the Zenphoto file of that name. You will have to spell out the full path to that file.

How is anotherfile.php being loaded?

I may be confused, but I suspect your are going down the wrong track. Remember that there is a separation of the server side and the client side of your site. PHP runs on the server side. jQuery (or any javascript) runs on the client side.

What this means is that you have to populate any jQuery details into the page WITH php. I suggest you download the development nightly build. There you will find an update Effervescence+ theme that has a jQuery gallery based on [i]ad-gallery[/i]. That may not be the gallery look you want but certainly it should give you insite on how these things are done.




Loading comments and exif data dynamically in jQuery - fuz3d - 17-12-2011

anotherfile.php is loaded via jQuery.

Here is the code:

`
function exifLoad(image) {

var album = $(".zp_uneditable_album_title").html();

var postData = {
"image" : image,
"album" : album
};

$.ajax({
type: "POST",
url: "/zenphoto/themes/mytheme/anotherfile.php",
data: postData,
success: function(data){
    $("#exif-panel").html(data);
}
});

}
And this is the changedanotherfile.php`:

`

`
Though now it doesn't throw any error, it doesn't display any data either. Nada. Blank.




Loading comments and exif data dynamically in jQuery - fuz3d - 17-12-2011

I would just like to add that I can load the images dynamically. It's just the comments and exif data of the selected photo.




Loading comments and exif data dynamically in jQuery - sbillard - 17-12-2011

Nop, it is not uploaded by jQuery. It may be referenced by jQuery as an URL, but not uploaded because, as I said, jQuery runs on the client, PHP runs on the server.

I think you have got a bit out of your league. This is really not how WEB services work.




Loading comments and exif data dynamically in jQuery - acrylian - 17-12-2011

A quick tipp: If you want to load a page dynamically via ajax/jquery that should be theme environment, use a custom theme page and the matching url (info on the theming tutorial).




Loading comments and exif data dynamically in jQuery - fuz3d - 18-12-2011

@sbillard, I [i]know[/i] jQuery is on client-side and PHP is on server-side. I'm not sure what you meant by 'loaded' and thought you were asking how the page is being called.

If I didn't know, I wouldn't have successfully be able to load the images directly via jQuery.




Loading comments and exif data dynamically in jQuery - fuz3d - 18-12-2011

Thanks @acrylian for the tip!