Administrator
Administrator
fretzl   2008-12-23, 18:29
#1

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 !

Member
Member
sbillard   2008-12-23, 20:26
#2

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.

Administrator
Administrator
fretzl   2008-12-23, 21:06
#3

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

Member
Member
sbillard   2008-12-23, 21:41
#4

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'];

Administrator
Administrator
fretzl   2008-12-24, 09:11
#5

Great! That is exactly what I was looking for.
Thank you sbillard!...and Merry Xmas.

Administrator
Administrator
fretzl   2008-12-25, 13:33
#6

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 '

Administrator
Administrator
fretzl   2008-12-25, 14:42
#7

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 '

Member
Member
mironb   2009-01-09, 22:37
#8

Hi
I have similar problem. On my index page I have random image with code:
`

Member
Member
sbillard   2009-01-10, 01:12
#9

Use instead of getRandomImage() getRandomImageAlbum()

Member
Member
mironb   2009-01-10, 12:21
#10

Ok so I change getRandomImage() to getRandomImageAlbum('Krajobrazy') but page does not working
That's my code now:
`

Administrator
Administrator
acrylian   2009-01-10, 12:37
#11

That is probably becasue the function is called getRandomImagesAlbum(). http://www.zenphoto.org/documentation/functions/_template-functions.php.html#functiongetRandomImagesAlbum

Member
Member
mironb   2009-01-10, 12:59
#12

Yes !! my mistake now working. thanks!

  
Powered By MyBB, © 2002-2026 MyBB Group.
Made with by Curves UI.