Ajax: Dynamically reloading image content in theme (working prototype)
dave8401
Joined: 2009-06-01
Posts: 129 |
![]() |
I'm working on an addition to Serge's greydragon theme (though this should work in other themes as well). My idea is to load images per ajax dynamically instead of refreshing the whole page (which causes some disruption). Wouldn't such a ajax-functionality (reloading pictures, etc.) be exciting???!!!! If interested you can have a look on my current test-site: I spoke to Serge about this, I fixed some obvious bugs based on his feedback but he requested me to also (re-) load item-/meta-data dynamically ('on Image change'). Now my question is 'How should I do this?':
As soon as I know how the server-side is done (e.g. rest), I think I will be able to complete this (I'm familiar with the basics of ajax/json with jquery, so I won't bother you here ;)). Thanks in advance for some guidance! BR, |
|
hukoeth
Joined: 2009-03-20
Posts: 127 |
![]() |
Hi David, Thank you, --- |
|
dave8401
Joined: 2009-06-01
Posts: 129 |
![]() |
Hi Uli, Thanks for the positive response. Not a big fan of attaching code to posts, but for the sake of simplicity I'm attaching here my current branch (you need to use the modified theme together with the modified thumbnav module!). My biggest headache is how to reload meta-/image-data. Any suggestions / help highly appreciated. BR, |
|
tkott
Joined: 2010-06-07
Posts: 225 |
![]() |
David, Finally, it would seem to me that the best way to reload the meta info is to indeed call the REST API (I imagine the ajax call can do a normal http post, though haven't done it myself) and then use javascript to change the description using the g-metadata class as the selector. You can probably somehow call the right html template as well, though I have no idea how. I look forward to trying this out, thanks! Tomek |
|
dave8401
Joined: 2009-06-01
Posts: 129 |
![]() |
@tkott: let's stick to this theme for the time being. let's find the best way how to do such things and then we can think about modification of other themes / new ajax themes. You can simply unzip greydragon.zip to your 'themes'-folder and thumbnav.zip to your 'modules'-folder. Then install the module and activate the theme in the admin section. Can u tell me which extension I have to install so that I could try the REST API with my local XAMPP server |
|
hukoeth
Joined: 2009-03-20
Posts: 127 |
![]() |
Hi, --- |
|
tkott
Joined: 2010-06-07
Posts: 225 |
![]() |
David, Quote:
Can u tell me which extension I have to install so that I could try the REST API with my local XAMPP server If you mean enabling REST, then it's the REST module that comes with Gallery 3. You can find more info in the REST API: http://codex.gallery2.org/Gallery3:API:REST. If you mean how do you use jQuery / PHP / etc to post things, here is a link to jQuery: http://api.jquery.com/jQuery.post/. Sorry if I misunderstood your question! Tomek |
|
dave8401
Joined: 2009-06-01
Posts: 129 |
![]() |
No, I meant the XAMPP-server: Can somebody advise me on which package I have to install to make it work? |
|
rak
Joined: 2010-08-09
Posts: 44 |
![]() |
If you're making the requests with ajax (which is what i think you want to do) then you can make the requests client side using jQuery and not worry about the PHP. |
|
tkott
Joined: 2010-06-07
Posts: 225 |
![]() |
Oh, sorry! That's probably a PEAR package. Here's the general info: http://pear.php.net/, and the more specific for the file: http://pear.php.net/package/HTTP_Request/. I think if you're using PHP 5.3, PEAR is automatically insalled, so you can run something like Tomek |
|
nivekiam
![]()
Joined: 2002-12-10
Posts: 16504 |
![]() |
That's really awesome! Is there a possibility this could be a module instead of being baked into a particular theme? Maybe at least the steps you've gone through laid out so someone else could bake it into their theme? |
|
Serge D
![]()
Joined: 2009-06-11
Posts: 2466 |
![]() |
@dave8401: OK, since GreyDragon theme is a base here, at least for now, I am going to hijack the code to play with it inside my theme. As I mentioned before I was looking for something like that to be added to the theme out of the box, but if it would become generic module, it could be great as well. Few comments: I began to go through your changes for thumb nav module. are you using name attribute as an id? in XHTML standard name attribute has been marked as depricated and for page to comply with the standard it would be nice if it could be replaced by sudo id. Thumb module now directly referencing resized image. It is not good, because user will loose ability to open a new page of the thumb itself. Alternative would be to use rel or rev attributes which are standard and put relevant info there. @tkott: yes, thumbnav is a module available here. |
|
dave8401
Joined: 2009-06-01
Posts: 129 |
![]() |
You rock! Thanks will give this a try. |
|
dave8401
Joined: 2009-06-01
Posts: 129 |
![]() |
Serge, I was asked to provide the modified version and did it without checking with you first. |
|
Serge D
![]()
Joined: 2009-06-11
Posts: 2466 |
![]() |
Dave, if you can keep me in the loop, I would appreciate it since I am waiting for final version. |
|
dave8401
Joined: 2009-06-01
Posts: 129 |
![]() |
@Serge: Yes, I will. @all: I'm having issues with the REST API call. I get a lot of 'Deprecated' warnings with the client-sample that's provided & finally a kohana-exception. Is anyone else having the same errors/warnings? I'm using PHP 5.3 & installed via PEAR:
Anyways, I will try it again tonight with a fresh install of RC2. |
|
hukoeth
Joined: 2009-03-20
Posts: 127 |
![]() |
Hi Dave, I'm not really an expert so this might be not the best approach but I personally would prefer if REST is left out of the equation. Let me know what you think, --- |
|
dave8401
Joined: 2009-06-01
Posts: 129 |
![]() |
I will check the module you mentioned. But I see one issue in this approach, pls. correct me if I'm wrong: For this reason I wanted to have only the bare minimum of information sent to the client whenever he enters the 'photo-page', the rest then upon request. What do you think about this? BR, |
|
nivekiam
![]()
Joined: 2002-12-10
Posts: 16504 |
![]() |
SergeD wrote:
I have modified thumbnav module to incorporate your idea about using list instead of just links. I don't see it on your site that used for the GreyDragon demo. Can you provide a link to that? I'd like to see the change. |
|
hukoeth
Joined: 2009-03-20
Posts: 127 |
![]() |
dave8401 wrote:
I will check the module you mentioned. OK how I imagine it is that you indeed only send the bare minimum to the client. Upon request (load next image e.g.) your javascript calls your controller (e.g. http://yoursite/gallery/ajaxview/itemid) and it passes just the information you need in the format you prefer. --- |
|
tkott
Joined: 2010-06-07
Posts: 225 |
![]() |
@hukoeth, Could you explain a bit more. I wasn't even aware you could do that! Do you mean that if you have a file ajaxview.php in the modules/ajaxview/controllers/ folder, you can specify a function to call via http://yoursite/gallery/ajaxview/itemid? Or perhaps just an example of this working? Thanks, Tomek! |
|
hukoeth
Joined: 2009-03-20
Posts: 127 |
![]() |
Hi, If you want some examples in Gallery then have a look at Navigation Carousel or Tag Faces (or any module that allows to change settings on the admin pages. Regards, --- |
|
Serge D
![]()
Joined: 2009-06-11
Posts: 2466 |
![]() |
What do you mean? nivekiam wrote:
|
|
nivekiam
![]()
Joined: 2002-12-10
Posts: 16504 |
![]() |
dave8401
Joined: 2009-06-01
Posts: 129 |
![]() |
Uli, you rock. Modified my prototype so that it's able to reload title and description of an image and added back/forward buttons. Prototype is now based on Greydragon-2.3.1. So here's my approach: 'On-Image-Reload' ( reloadData(id) ) I'm sending the Item-ID to the controller GreyDragon_Controller. Now the cool thing: The controller sends back the element, a selector and the new value. By doing this the controller can send as many information as needed and the client-javascript replaces the elements on the website. I think this is a very simple & flexible approach. What's your opinion? See it in action here. BR, |
|
hukoeth
Joined: 2009-03-20
Posts: 127 |
![]() |
Wow this is awsome!!! It works on my installation just fine. Only problem I see is to get other modules to work correctly. It would be cool if there was a way that the controller could figure out what information is used on a normal page load and send all of it...which then just leaves the JavaScript which needs to know where to update the DOM... complicated. Maybe the devs can give some pointers? --- |
|
dave8401
Joined: 2009-06-01
Posts: 129 |
![]() |
Uli, you're right (again). I think we should discuss the 'session-handling' first with the core-team. Right now I'm doing this via the #URL-POSTFIX. |
|
dave8401
Joined: 2009-06-01
Posts: 129 |
![]() |
Hi Serge, Here an update version:
I encountered 1 problem though: Thanks, |
|
Serge D
![]()
Joined: 2009-06-11
Posts: 2466 |
![]() |
Just did quick test: |
|
dave8401
Joined: 2009-06-01
Posts: 129 |
![]() |
@serge: did you use the jquery.galleriffic.js that's bundled within my zip-file or did you use the standard-one? |
|
Serge D
![]()
Joined: 2009-06-11
Posts: 2466 |
![]() |
I was looking at your web-site |
|
dave8401
Joined: 2009-06-01
Posts: 129 |
![]() |
can u try again? cannot test ie as i'm working on a mac (seems to work now in safari and firefox) |
|
Serge D
![]()
Joined: 2009-06-11
Posts: 2466 |
![]() |
nope, does not do anything when clicking on the button |
|
dave8401
Joined: 2009-06-01
Posts: 129 |
![]() |
can u try once again? |
|
Serge D
![]()
Joined: 2009-06-11
Posts: 2466 |
![]() |
much better! I now need to think what to do with preview functionality (popup window opened on click in current theme's version) you have removed in yours |
|
dave8401
Joined: 2009-06-01
Posts: 129 |
![]() |
serge, i will look into the navigator this evening. my plan is to modify paginator.html.php slightly to achieve this. Will keep you posted about my progress! |
|
Serge D
![]()
Joined: 2009-06-11
Posts: 2466 |
![]() |
ok |
|
dave8401
Joined: 2009-06-01
Posts: 129 |
![]() |
serge, here my first draft: what do you think? my idea is simple:
need your help on this: |
|
Serge D
![]()
Joined: 2009-06-11
Posts: 2466 |
![]() |
seems to be working, but
|
|
Shemo725
Joined: 2008-04-18
Posts: 424 |
![]() |
hmn..I can't get the theme to even work properly with the greydragon zip that was attached in this thread. http://gallery.andrewshemo.com/index.php I also uploaded the shadowbox from the modules page and the thumbnav module that was uploaded in this thread |
|
dave8401
Joined: 2009-06-01
Posts: 129 |
![]() |
@serge: paginator isn't fully working ... i'm aware of this.
@shemo725: |
|
mamouneyya
Joined: 2009-11-02
Posts: 337 |
![]() |
Any chance to get this working independently of GrayDragon theme? (i.e. make it as a module.) |
|
Shemo725
Joined: 2008-04-18
Posts: 424 |
![]() |
@ dave..a bunch of stuff isn't working.......there's no login option on the main page, the albums aren't having any hover effects, the top menus don't have any drop downs and there's a bunch of white dots near the sidebar..see the attachments. |
|
Serge D
![]()
Joined: 2009-06-11
Posts: 2466 |
![]() |
@mamouneyya: From what I have seen so far: I think it would be very hard to make it a module, at least at this stage. There is a lot of core code modifications in the theme. when code is stabilized, then there could be a chance to make it more abstract. But we are getting there |
|
dave8401
Joined: 2009-06-01
Posts: 129 |
![]() |
100% agree with serge: use the released greydragon-theme from serge and you will be fine for the time being. this is highly experimental ... with a lot of hacks. @serge: can u help me with the position (the rank) of an item within an album? this might also fix some of the issues from shemo75 ... |
|
Serge D
![]()
Joined: 2009-06-11
Posts: 2466 |
![]() |
look at original theme's photo.html.php Also it would allow you minimize changes to the page as well since you can enumerate list of items where class is g-sb-preview - used by photo slideshow today. |
|
dave8401
Joined: 2009-06-01
Posts: 129 |
![]() |
original is wind or greydragon? |
|
Serge D
![]()
Joined: 2009-06-11
Posts: 2466 |
![]() |
greydragon |
|
dave8401
Joined: 2009-06-01
Posts: 129 |
![]() |
serge, agree to you're statement about ids. switched it back to a version that's based on item-ids. main problem that i see right now are the … in the current paginator. to set them correctly with all those dom-manipulation that we are doing is tough. How could go about them? |
|
rross
Joined: 2010-08-22
Posts: 41 |
![]() |
I thought I'd pipe in and let you know that I'm also interested in this theme. I saw your test site and it's pretty much what I hoped Gallery would do when I recently downloaded it. I like the simplicity of the slideshow and the ability to keep the thumbs and main display visible from photo to photo without scrolling down in the browser. I'm not sure it's part of what you're doing, but it would be nice to make the thumbs a little larger and maintain the ratio aspect. Keep up the good work! |
|
Serge D
![]()
Joined: 2009-06-11
Posts: 2466 |
![]() |
@rross: i would suggest you try the theme by itself. |
|