The commercial theme for Galleria "twelve" extends Galleria core with more options.

This patch adds support for these options.

CommentFileSizeAuthor
support_twelves_options.patch1.24 KBBevan
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

miro_dietiker’s picture

Since every custom theme might add some new options, this possibly needs a plugin hook...
It's already confusing to set options while you don't know if a theme supports this or not...

Any suggestion about extensibility?

kroimon’s picture

Title: Support twelves options » Add support for theme-specific options
Version: 7.x-1.0-beta2 » 7.x-1.x-dev

I think we should support the extended options for the "official" themes out of the box, but they should only be visible when the belonging theme is installed.

So thanks for your patch, Bevan. I'll have a look at the other theme's options asap.

@miro_dietiker: The problem with a plugin hook is: Do you really want to install and enable a new module for every custom theme just to have support for the theme-specific options?

Bevan’s picture

I think a "custom option" option would be useful for custom themes and more obscure public themes.

I agree that these options should only be exposed by themes that support them.

I wonder if there is a way to parse the theme's JS from PHP and work out what the options are. Perhaps if the library can be instantiated client-side in a hidden iframe or div and the keys of galleria.options can be sent back to the server via AJAX?

miro_dietiker’s picture

Since users are generally free in implementing a plugin and what it supports, the code might be diffrent from case to case.
We'll need to define a way in how to define the option.
We better define some additional file format (e.g. containing some JSON data).

kroimon’s picture

@Bevan: Well, there IS a "custom option". Just type in any option name you want instead of selecting one from the drop-down list! You get a text input for each unknown option. If you need boolean values, enter "true" or "false", they will be converted accordingly.

Bevan’s picture

If you are going to require that each theme have an "option definition list" defined in code, that will always be specific to Drupal, so you might as well do it in PHP in the module, or in custom modules via hook_galleria_options() or CUSTOM.galleria.inc.

However you can retrieve the list of options from the javascript file by letting the admin's browser parse the file for you, as I alluded to in comment #3. It's tricky, but manageable. The possible options get stored in the database.

  • Create a Drupal menu items for galleria/get-options and galleria/set-options
  • In it's menu handler return markup with
    • minimal chrome/styles (e.g. maintenance-page.tpl.php)
    • all of gallerias JS, dependencies and known themes
    • Drupal.settings (or equivalent) with the list of hard-coded options. i.e. array_keys(galleria_option_elements())
    • A custom JS file which does the following magic:
      • For each Galleria theme that has registered itself with Galleria;
        • Instantiate a Galleria object and initialise it to use that theme
        • Retrieve the _options property from the Galleria object
        • Iterate over it to build/append to an object with the same keys, but the value is the type of the value from _options.
      • Submit that new array as JSON to galleria/set-options.
  • In the menu callback for galleria/set-options, save the options and their types (e.g. Boolean, Integer, String) to the database.
  • Respond with an okay status and maybe a URL to redirect to.

Well, there IS a "custom option".

So there is. I had not noticed the feature. I think it could be made more notice-able in the UI.

kroimon’s picture

The problem with the dynamic loading idea is that we would just have more option names in the select box, but noone would know what they are for, because we don't get any description or documentation for them.
So I think the only manageable way is to add them manually to the list, maybe depending on which theme is selected.

So there is. I had not noticed the feature. I think it could be made more notice-able in the UI.

Well... how? Currently, there is the "Select or enter:" text next to the "Add option" button, and it is selected by default! You have to manually select an option for the input field to vanish...

kroimon’s picture

Issue summary: View changes

Adding a URL to the demo for the twelve theme.