Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Google Sign In with OpenID

apps/app_name/conf/embed.php

edited April 2013 in Apps

I'm still trying to learn my way around the documentation, so I probably just missed this. However, I didn't see answers to these questions here: http://www.elefantcms.com/wiki/Dynamic-handlers-and-the-wysiwyg-editor

What are the allowed values for icon? picture, ...

Is there a way to specify choices without using a callback function, ie just hard code a list of options?

Comments

  • edited February 2013

    Ah yes, the docs need some updating... You can either specify an image, or use any of the icons found here:

    http://fortawesome.github.com/Font-Awesome/

    You just leave out the icon- prefix in Elefant :)

  • Thanks. What about hard-coding choices? Is something like this possible?

    param[options] = "value1|value2|value3"

  • I'm afraid not at the moment, no. The easiest way is just to create a class with static methods, like this:

    <?php
    
    class MyClass {
        public static function values_for_embed () {
            return array ('yes', 'no', 'maybe');
        }
    
        public static function values_with_keys () {
            return array (
                array ('key' => 'yes', 'value' => __ ('Yes')),
                array ('key' => 'no', 'value' => __ ('No')),
                array ('key' => 'maybe', 'value' => __ ('Maybe'))
            );
        }
    }
    

    Save that to your app's lib folder (e..g, apps/demo/lib/MyClass.php), then you can include the values like this:

    ; <?php /*
    
    [demo/hello]
    
    label = Hello World
    icon = picture
    
    param1[type] = select
    param1[label] = Option 1
    param1[callback] = "MyClass::values_for_embed"
    
    param2[type] = select
    param2[label] = Option 2
    param2[callback] = "MyClass::values_with_keys"
    
    ; */ ?>
    
  • edited March 2013

    I was thinking that using values_with_keys would cause the dynamic object to embed the key, but it seems to be embedding the value. For example, I was expecting param2=maybe but it seems to be embedding param2=Maybe.

    Edit: Never mind; I just looked at your example again. I was thinking it was array( 'key' => 'value'), but it's array ( array ( 'key' => 'key1', 'value' => 'value1' ) ). I take it 'key' has to be 'key' and 'value' has to be 'value'?

  • That's right, it needs the sub-array to have the 'key' and 'value'.

Sign In or Register to comment.