ZenphotoCMS Forum
Random Thumbnail? - 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: Random Thumbnail? (/thread-2286.html)

Pages: 1 2


Random Thumbnail? - oceanagency - 26-02-2008

Hi,

I have ZenPhoto and WordPress installed. They work a dream

However, I'm running into problems displaying a random thumbnail on my sidebar in WordPress?

I've looked at and tried Hacks and Extensions found in this forum and site, but am none the wiser. Up til 2am on a work-night was not good

Can someone please hold my hand and help me along this treacherous path?

Many thanks.




Random Thumbnail? - invision - 28-02-2008

Hate to bump, but any takers?

I'm really racking my brain on this one.

ZenPhoto is fully installed and working a dream, but I've had no such luck with the Random Thumbnail.

Thank you.

P.S Lost my password for 'invision', then found it again :d




Random Thumbnail? - acrylian - 28-02-2008

Please take a look here: http://www.zenphoto.org/2008/01/hacks/#zenphoto-as-plugin




Random Thumbnail? - invision - 28-02-2008

Thanks for the reply.

I've looked there and seen these two parts

`define('ZENFOLDER', 'zp-core');

define('WEBPATH', 'zenphoto');

require_once(WEBPATH . "/" . ZENFOLDER . "/template-functions.php"); and $randomImage = getRandomImages();

$randomImageURL = getURL($randomImage);

echo "';`

Have already tried the above code before, but maybe I'm not using it right. Can you give me an example?

So I have my sidebar my WP theme, which is used for my ZP also.

How should I place the random thumbnail generator code into 'sidebar.php'?

Thankyou.




Random Thumbnail? - BertSimons - 28-02-2008

hi the way I integrated my latest, and most popular images in my wp-sidebar (see: http://www.bertsimons.nl/zenphoto/) in this way;

I make a php file called latest.php or in your case randomimage.php with content:

`




Random Thumbnail? - sbillard - 28-02-2008

Zenphoto needs a bit more than your theme file to function, so just doing an include on it will not work. You need the
`define('ZENFOLDER', 'zp-core');

define('WEBPATH', 'zenphoto');

require_once(WEBPATH . "/" . ZENFOLDER . "/template-functions.php");`
code in your sidebar to setup zenphotos environment.

Ov course zenphoto needs to be the folder where zenphoto was installed.




Random Thumbnail? - BertSimons - 29-02-2008

sbillard, those calls I already included.

Other zenphoto functions , like most popular, latest images and taglist get embedded in the wp-sidebar without a problem as you can see on my site. except for when using the printRandomImages(); I get the mysql error




Random Thumbnail? - sbillard - 29-02-2008

I really don't know what could be causing this. The following code is working as we speak on my test site testalbum-2.sbillard.org
`

Test Index




Random Thumbnail? - invision - 29-02-2008

I get the following error when I plug that into my site

`Warning: main(zenphoto/zp-core/template-functions.php) [function.main]: failed to open stream: No such file or directory in /home/michaelsiteuk/public_html/michaels/zenphoto/test.php on line 4

Fatal error: main() [function.require]: Failed opening required 'zenphoto/zp-core/template-functions.php' (include_path='.:/usr/share/pear') in /home/michaelsiteuk/public_html/michaels/zenphoto/test.php on line 4`

But there definitely is a 'template-functions.php' file in the zp-core folder

I placed that code, on its own, into a file :
www.mysite.com/myfolder/zenphoto/test.php

and my WP is at :
www.mysite.com/myfolder/wordpress/

And still it won't work.

Any ideas?

Thank you for your time.




Random Thumbnail? - acrylian - 29-02-2008

Ok, then the path to your zenphoto folder seen from WP would not be "zenphoto" but "../zenphoto".




Random Thumbnail? - sbillard - 29-02-2008

The folder structure of my site was:

Root folder (..testalbum-2/htdocs): contains the above index.php file
zenphoto folders (..testalbum-2/htdocs/zenphoto) contains all the zenphoto files.

Your test.php should probably be in the michaels folder.




Random Thumbnail? - BertSimons - 01-03-2008

sbillard, with your code the same..the first part to generate the latest images works, the randomimages functions returns the mysql error off which i've placed a screenshot here

http://www.bertsimons.nl/zenphoto/albums/various/publicity-photos/Screenshot.png




Random Thumbnail? - sbillard - 01-03-2008

I am at a loss, there is some kind of conflict in your setup. http://testalbum-2.sbillard.org/ does not get any errors, but then Wordpress is not involved at all.




Random Thumbnail? - BertSimons - 01-03-2008

just did a fresh install of zenphoto 1.1.5 together with a new database and using the default theme.
so no wordpress involved and inserted the latest and random image code in the default theme.

but..same error output from the printRandomImages()....

as seen at http://www.bertsimons.nl/zenphototest/




Random Thumbnail? - acrylian - 01-03-2008

Strange thing, I can't reproduce that with a clean 1.1.5 install, too. Maybe this is a PHP/MySQL-version problem? Which versions do you run? I have PHP 5.2.3/MySQL 5.0,41.




Random Thumbnail? - gregb34 - 01-03-2008

i just try and it works fine.

But testing printRandomImages() i have seen thaht we can specify 'album' in $option.

function printRandomImages($number=5, $class=null, $option='all')

but after i see :

case "album":
$randomImage = getRandomImagesAlbum(); break;

Where we can specify the album name ?

Thanks.




Random Thumbnail? - acrylian - 01-03-2008

You can't, it simply built to return random images of the whole gallery or the current album (and/or its subalbusm) you are within...

EDIT: Strange thing is that we have a line in the documentation of getRandomImgesAlbum that speaks of an option to get an album folder, but the option itself is not there. Maybe something got lost on the way or was forgotten...




Random Thumbnail? - BertSimons - 01-03-2008

acrylian, I use PHP version 4.3.10/MySQL version 3.23.58




Random Thumbnail? - sbillard - 01-03-2008

GetRandomImagesAlbum() does provide for the option to specify the album from which the images are obtained. If empty it uses $_zp_current_album. However, printRandomImages() does not have such a parameter, so it only uses the current album. It will be relatively easy to extend printRandomImages() to add this parameter and pass it throught to getRandomImagesAlbum().




Random Thumbnail? - sbillard - 01-03-2008

BertSimons:

Does getRandomImages() work fopr you within Zenphoto? You can setup stopdesign to use it through the options.