![]() |
|
printAlbumzip () fails - persistence? - Printable Version +- ZenphotoCMS Forum (https://forum.zenphoto.org) +-- Forum: Support (https://forum.zenphoto.org/forum-1.html) +--- Forum: General support (https://forum.zenphoto.org/forum-4.html) +--- Thread: printAlbumzip () fails - persistence? (/thread-8815.html) |
printAlbumzip () fails - persistence? - teeps - 04-07-2011 Hi, Any time I try to use the printAlbumzip function on an album I get this error: This is the code I've added into a codeblock to call the function: ` I've enabled persistent archives in the options, not sure if that has helped as the same error is given either way. Does this function work for others, or is this a wider problem not specific to me? Thanks! printAlbumzip () fails - persistence? - sbillard - 04-07-2011 This is probably a context issue with the codeblocks. Try adding the printAlbumzip () fails - persistence? - teeps - 05-07-2011 I changed the codeblock to: ?php if (function_exists ('printAlbumZip')) { global $_zp_current_album; printAlbumZip();} ?> ` Unfortunately I still get the same error. printAlbumzip () fails - persistence? - sbillard - 05-07-2011 Well the error is caused by $_zp_current_album not being an object. If the global did not help then there is some other reason. Perhaps the codeblock call is out of the scope of album context. Do some debug output--see what the value of $_zp_current_album is before your call. printAlbumzip () fails - persistence? - teeps - 05-07-2011 In the codeblock: Just for info I echoed $_zp_gallery->getTitle () but that just returned an empty result. So next I added these lines to album-zip.php just before the line that was giving me a problem:
` Now I get the 'Call to a member function getTitle() on a non-object' error on that second echo (the $_zp_gallery one), so it looks like it's losing the context somewhere maybe? I'm not great on classes and objects, so this is guesswork for me. printAlbumzip () fails - persistence? - teeps - 06-07-2011 I just noticed that the link being called by the printAlbumZip() function is wrong - it's passing the album title in lowercase, i.e. If I manually change the url in the browser window to use the correct case for the album title (i.e. with a capital R, as in album-zip.php?album=Randoms) I do not get the 'non-object' error - I still don't get a zip file but that's another problem. How can I ensure that the printAlbumzip function passes the correct album name with the correct case? printAlbumzip () fails - persistence? - teeps - 06-07-2011 I changed line 3081 in template-functions.php to
Previously it used $_zp_current_album->name in the pathurlencode function. After this change it passes the correct album title and I don't get the non-object error. I am still looking into why I don't get a zip file output. printAlbumzip () fails - persistence? - teeps - 06-07-2011 Forget the previous two posts (especially as the code went funny in the last one), apparently using getTitle() is a red-herring. I tried it with an album that is named in lowercase and it gave the non-object error again, so I deduce that album names are in fact lower case, and that's what needs to be passed. Giving a name with upper case produces the same as giving album-zip.php a completely made up name. So, next I tried commenting out line 66 of print-album.zip ($persist = $_zp_gallery->getPersistentArchive() and adding $persist = NULL; instead. This works in the sense that the zip file is created, but presumably there's no caching going on, so every request will create a new file. printAlbumzip () fails - persistence? - sbillard - 06-07-2011 So then, the problem is only if the persistent arcive option is set? (You can reset that on the options page to be sure.) printAlbumzip () fails - persistence? - teeps - 06-07-2011 I get the same result whether the persistent archive option is set or cleared. printAlbumzip () fails - persistence? - sbillard - 06-07-2011 change that line to printAlbumzip () fails - persistence? - teeps - 06-07-2011 That seems to have solved it, thanks sbillard! |