Adding SELECT attribute options for a page
Permalink
I have created the SELECT attribute as follows
Now I want to add the values (options) per page level
The above code will add the options globally, but I want it in page level.
I'm trying the following code, but it is not working
How to add the SELECT attribute for a page, so that I can get the following values
Thanks in advance for your help,
Bala
CollectionAttributeKey::add('tab_attr', t('Tab Attribute'), false, null, 'SELECT');
Now I want to add the values (options) per page level
$ak=CollectionAttributeKey::getByHandle('tab_attr'); SelectAttributeTypeOption::add( $ak, 'Tab1', 0, 0);
The above code will add the options globally, but I want it in page level.
I'm trying the following code, but it is not working
$curPage = Page::getCurrentPage(); $curPage->setAttribute($ak, 'Tab1');
How to add the SELECT attribute for a page, so that I can get the following values
$options = $curPage->getCollectionAttributeValue('tab_attr');
Thanks in advance for your help,
Bala

You can't have different options for different pages. The options of the select attribute (or any attribute for that matter) will be the same across the whole site. If you want different options for different pages you would need to create different attributes.
Hi Jordan
If I follow the steps manually, as mentioned in the below page, I'm able to get different options for the same attribute
http://www.concrete5.org/documentation/how-tos/developers/creating-...
I'm just wondering, how to do this through scripting
Thanks,
Bala
If I follow the steps manually, as mentioned in the below page, I'm able to get different options for the same attribute
http://www.concrete5.org/documentation/how-tos/developers/creating-...
I'm just wondering, how to do this through scripting
Thanks,
Bala
While the attribute has a single set of options, you could subset those options shown for a particular page with some jQuery.
This would obviously require some development work and would need to be loaded and execute when the attribute value was edited.
// This is jquery-ish pseudo-code to outline the solution switch (page_path) case 'a/page/path' $(the_attribute_select options).each(function(){ if (this_option_value is_not_wanted){ $(this_option).remove() } }); // etc....
This would obviously require some development work and would need to be loaded and execute when the attribute value was edited.
Able to save the options
and getting the values properly by using $curPage->getCollectionAttributeValue('tab_attr');
Thanks,
Bala
$opt = SelectAttributeTypeOption::add($ak, 'Tab1', 0, 0); $curPage->setAttribute($ak, $opt);
and getting the values properly by using $curPage->getCollectionAttributeValue('tab_attr');
Thanks,
Bala
getting some problem with saving multiple options :(
As Jordan said, I think its better to have separate attributes per page.
Can anybody please tell me how multiselect works for a page
Thanks,
Bala
As Jordan said, I think its better to have separate attributes per page.
Can anybody please tell me how multiselect works for a page
Thanks,
Bala
Multiselect shows on the page properties as a list of checkboxes that you tick.
ya, actually I'm hiding it for the enduser, and managing it on my own, there I'm facing the pbm.
Basically I'm creating a TAB component based on this SELECT attr.
Basically I'm creating a TAB component based on this SELECT attr.