Zenphoto 1.2.2 [3131],customized default theme.
My index.php has a random image from the gallery.
What I need to do for the user is:
[list]
[]Add a theme option to be able to choose from which album or subalbum the random image should be taken. (a list with all albums and subalbums?)
[]The user should also still be able to choose for a random image taken from the entire gallery.
(a checkbox to override the album list?)
[/list]
After two days of trial and error coding and a headache I give up
Any help is much appreciated.
Merry Xmas to you all !
There are two different functions you will be using: getRandomImages() for random images from the entire gallery and getRandomImagesAlbum($album) for random images from a particular album.
If your user selects to use images from the entire gallery your task is fairly simple. use $image = getRandomImages(); to establish the image. Then go to the display process below.
If your user selects random image from a particular album do the following (I assume you have the album name as a string $albumname):
create a new album: $album = new Album($_zp_gallery, $albumname); Then get the random image: $image = getRandomImagesAlbum($album);
Now that you have an image you need to make it the current image: makeImageCurrent($image);
Then you print using one of the template functions for printing images.
Thanks sbillard !
I understand your answer (I think ). That's the part that should be coded in my index.php.
My real problem however is to [b]make[/b] it a custom theme option in the
theme options page. (admin -> options -> theme options)
The user wants an easy way to regularely change the the source of the random image.
I can't figure out how to make a list with all the album names to choose from and a checkbox to override this list so the image will be chosen from the entire gallery.
(or any other construction that works)
I'm sorry if I made myself not clear enough ...again.
Thanks again
I presume you have looked at the other themes themeoptions.php scripts to see how theme options are done in general. You should also look at the function description for customOptions() for the types of options that are handled in a straight forward manner.
So, all you really need is how to get a list of albums to use in a type 5 custom option. Your quickest solution would be to use a query.
$albumlist = query_full_array("SELECT folder FROM ".prefix('albums')); will give you all the albums. You will need to extract the folder name into a single dimensioned array for the option handling:
foreach ($albumlist as $album) $list[] = $album['folder'];
Just in case anyone is interested, here's what I put together:
On the admin -> options -> theme options page I now have a list with all albums (subalbums included) to choose from + an option to select the entire gallery.
[b]In themeoptions.php:[/b]
function ThemeOptions() {
setOptionDefault('Allow_comments', true);
setOptionDefault('Allow_search', true);
[b]added [/b] 'setOptionDefault('Randomimage, 'Gallery');'
}
function getOptionsSupported() {
return array(
gettext('Allow comments') => array('key' => 'Allow_comments', 'type' => 1, 'desc' => gettext('Check to enable comment section.')),
gettext('Allow search') => array('key' => 'Allow_search', 'type' => 1, 'desc' => gettext('Check to enable search form.')),
[b]added[/b]
gettext('Randomimage') => array('key' => 'Randomimage', 'type' => 2, 'desc' => gettext('Select source for random image')),
}
function handleOption($option, $currentValue) {
switch ($option) {
case 'Theme_colors':
$theme = basename(dirname(FILE));
$themeroot = SERVERPATH . "/themes/$theme/styles";
echo '
OK that was not very clear...I'll try again:
Just in case anyone is interested, here's what I put together:
On the admin -> options -> theme options page I now have a list with all albums (subalbums included) to choose from + an option to select the entire gallery.
In themeoptions.php:
[b]in[/b] function ThemeOptions()
[b]I added:[/b] setOptionDefault('Randomimage, 'Gallery');
[b]in[/b] function getOptionsSupported()
[b]I added:[/b] gettext('Randomimage') => array('key' => 'Randomimage', 'type' => 2, 'desc' => gettext('Select source for random image')),
[b]in[/b] function handleOption($option, $currentValue) [b] (which I copied from the Effervescence+ theme)[/b]
[b]I added:[/b]
`
case 'Randomimage':
$albumlist = query_full_array("SELECT folder FROM ".prefix('albums'));
foreach ($albumlist as $album) $list[] = $album['folder'];
$list[] = '--Gallery--';//add option for entire gallery to array
echo '
That is probably becasue the function is called getRandomImagesAlbum(). http://www.zenphoto.org/documentation/functions/_template-functions.php.html#functiongetRandomImagesAlbum