Theme Options

Cbunny Member
Hello -

I'm playing around with creating a theme and don't quite know where to find documentation on theme options.

Here are things that I understand...

1) Some theme options are set in a theme's themeoptions.php file.
2) The function is called ThemeOptions()
3) To set options in the themeoptions.php you use setOptionDefault(___, ___)

What I don't understand is...

1) Where is this function (class?) ThemeOptions() located?
2) How do I know what options I can set?
3) What is the difference between setOptionDefault() and setOption()?

I have been looking at the Stopdesign files because they are pretty organized.

So in the Stopdesign themeoptions.php file there is this code...

`class ThemeOptions {

function ThemeOptions() {

/* put any setup code needed here */

setOptionDefault('Allow_comments', true);

setOptionDefault('Allow_search', true);

setOptionDefault('Gallery_description', 'You can insert your Gallery description using on the Admin Options tab.');

setOptionDefault('Mini_slide_selector', 'Recent images');

}`

But when I got to my admin page I see that my Mini slide selector has been set to Random images (which is what I changed it to). Why doesn't is go back to default if I move away from the theme. Not that I'm complaining, I just don't understand why. And also there are only four setOptionDefault values here but on the theme options tab there are 12 options. The discrepancy leads me to thing that there are other things going on that I'm not aware of.

And then I look at the index.php for the Stopdesign theme and see these thumb_crop_height/width in the <head>...

`

<?php printGalleryTitle(); ?>



/css/master.css" />

<?php <br />
printRSSHeaderLink('Gallery','Gallery RSS');

zenJavascript();

setOption('thumb_crop_width', 85, false);

setOption('thumb_crop_height', 85, false);

?>

`

So these setOption items *seem* to correspond to the theme options in the options tab BUT they don't update either as when I use this theme AND there are three variables for setOption not two like setOptionDefault.

Where do I find information on these things? I've scoured the online documentation and searched through my actual files for these strings and I'm confused.

Would it be helpful to start asking this stuff on the IRC?

Thanks.

Nif

http://www.crankybunny.com

Comments

  • Have you looked at http://www.zenphoto.org/2008/05/theming-tutorial/? Also of interest would be http://www.zenphoto.org/2008/04/zenphoto-plugin-architecture/ which describes the plugin architecture (Themeoptions are a class of Zenphoto plugin.)

    Some quick answers to your questions:

    #1 The `themeoptions` class is defined in the theme's themeoptions.php script.
    #2 You can set any options that the `themeoptions` class defines.
    #3 `setOptionDefault()` sets the default value of the option. What that means is that if the option currently has not had a value set it will set the value. If the option already has a value it does nothing. `setOption()` always changes the value of the option.

    The themeoptions.php script defines options that are specific to the theme. There are also options (primarily about image display) that all themes have in common. These are defined by Zenphoto.
  • Cbunny Member
    Thanks for the reply - more questions though...

    I checked out the plugin architecture and don't quite get some things quite yet...

    "The current Zenphoto implementation makes use of two classes: spamfilters and themeoptions."

    So this is saying that the `themeoptions` class is something defined by the theme creator (but is an "official" class recognized by ZenPhoto).

    However - where do I find info on the options that all themes have in common? And how do they end up on the theme options page?

    #3 - but the `setOption()` items in the Stopdesign code from above did not seem to overwrite the values shown in the theme options tab. And why are there three values passed instead of two?

    Thanks!
  • The `themeoptions` class is specified by the Plugin Architecture. Each theme may create an instance of this class that does the particular option handling it requires.

    Admin.php defines the common options and causes them to appear on the theme options page. (It also causes the theme-specific options to appear on the theme options page. and handles all other options as well.)

    #3 If you review the functions guide http://www.zenphoto.org/documentation-official/zenphoto/_functions.php.html for `setOption()` you will see that the third parameter allows the setting of the option to be non-persistent. This accounts for the behavior you observe.
  • Cbunny Member
    OK - I see now about the themeoptions class and I have taken a look at admin.php - I think I am starting to understand how stuff works together a litte better.

    Was that the correct link for `setOption`? I searched the page and nothing showed up.

    Thanks.
  • There is no direct link. Visit the link above and do a page search for setOptions()
Sign In or Register to comment.