Closed (fixed)
Project:
Variable
Version:
7.x-2.2
Component:
Documentation
Priority:
Normal
Category:
Support request
Assigned:
Issue tags:
Reporter:
Created:
14 Jun 2013 at 12:20 UTC
Updated:
1 Oct 2013 at 08:18 UTC
I can create a variable with "multiple" type depend on some other parameter, for example:
$variables['node_options_[node_type]'] = array(
'type' => 'multiple',
'title' => t('Default options', array(), $options),
'repeat' => array(
'type' => 'options',
'default' => array('status', 'promote'),
'options callback' => 'node_variable_option_list',
),
);
It's ok, but how to create a custom variable with "multiple" type?
Is it even possible?
I think it's possible and can be very useful for the others. I'm trying to figure out this on my own and this is what I've got so far:
/**
* Implements hook_variable_info().
*/
function MY_MODULE_variable_info($options) {
// my custom variable
$variables['custom_variable'] = array(
'type' => 'multiple',
'title' => t('My custom variable', array(), $options),
'children' => array(
'first_variable' => array(
'type' => 'string',
'index' => 0,
'name' => 'first_variable',
'module' => 'MY_MODULE',
'title' => t('My first variable', array(), $options),
'default' => 'First value',
'token' => TRUE,
),
'second_variable' => array(
'type' => 'string',
'index' => 1,
'name' => 'second_variable',
'module' => 'MY_MODULE',
'title' => t('My second variable', array(), $options),
'default' => 'Second value',
'token' => FALSE,
),
'third_variable' => array(
'type' => 'string',
'index' => 2,
'name' => 'third_variable',
'module' => 'MY_MODULE',
'title' => t('My third variable', array(), $options),
'default' => 'Third value',
'token' => FALSE,
)
),
'group' => 'site_information',
);
return $variables;
}
Obviously, this is not the way it should be, but as I mentioned in the title - there is no documentation, examples, anything.
Comments
Comment #1
jack-pl commentedOk, I solve it by my own. Hope it will be useful for someone.
Comment #3
marcvangendThanks for posting, Jacek.