• Resolved lunarartist

    (@lunarartist)


    First things first: excellent plugin development. It’s full of potential, and easy to implement… top job. πŸ™‚

    Now, I’m trying to work out a way to define the options of a select / checkbox set using values that are contained elsewhere in the database.

    For example, if you have a list of locations as Pages, and you then want to create an event that is to occur at one of those locations, there should be a ‘Location’ custom field which would have a list of options based on the location pages available…

    Is there any development that would allow these options to be gathered through a standard query? (Is there an established method for executing PHP within the template options of this plugin?)

    I’ve yet to look at the plugin code thoroughly myself (I’m not particularly skilled with PHP anyway…), but I thought maybe this functionality was already being looked into elsewhere…

    Many thanks in advance for any assistance.

    http://ww.wp.xz.cn/extend/plugins/custom-field-template/

Viewing 1 replies (of 1 total)
  • I released the version 0.6.4. You can use PHP codes in order to set values of radio and select types. (I am sorry that you can not use php codes in checkbox right now.) See the option page.

    This is an example to show a select list of post titles under a certain category.

    β€”- Template
    [posts]
    type = select
    code = 0
    β€”-

    β€”- CODE# 0
    $values = array();
    $posts = get_posts(‘category=1’);
    foreach($posts as $post) {
    $values[] = $post->post_title;
    }
    β€”-

    Basically, you need to set $values as an array. you can also set $default also. Here is an easier example.

    β€”-
    $values = array(‘dog’, ‘cat’, ‘monkey’);
    $default = ‘cat’;
    β€”-

    You can set any values by using your own code. However, do not forget to do it at your own risk.

    I hope this option will work properly for you.

    Thanks.

Viewing 1 replies (of 1 total)

The topic ‘[Plugin: Custom Field Template] Populate dropdown / tickbox options dynamically (using PHP?)’ is closed to new replies.