3093 Posts in 875 Topics by 654 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 975 Views |
-
Compare dynamic page-attributes

17 September 2010 at 6:49pm
I need to compare products on my page.
The product-pages are grouped by holders.
My plan is to setup an arbitrary list of attribute-fields for each holder, that can be filled-in in the product-page administration.Anyone around who can give assistance? Is there a best practice?
-
Re: Compare dynamic page-attributes

30 September 2010 at 12:12am
Nobody who could give a hint for a product comparison?
-
Re: Compare dynamic page-attributes

30 September 2010 at 12:34am
I think we'd need some more info... what is your dataobject page you are looking to compare, can you include code?
-
Re: Compare dynamic page-attributes

30 September 2010 at 2:51am
Thank you swaiba for your reply.
I do not have code to show yet. I'm just searching for the right approach.
To compare products I'll need to have extendable attribute keys which I'd like to declare with the product-group (holder).
But I've no idea how to store the values to each product. -
Re: Compare dynamic page-attributes

30 September 2010 at 2:59am
are you intending to use the eCommerce module?
-
Re: Compare dynamic page-attributes

30 September 2010 at 7:17am Last edited: 30 September 2010 7:19am
No. It's just a product presentation, no shop.
Now here's my first approach:
class ProductAttribute extends DataObject {
static $db = array(
'Attribute' => 'Text',
'Value' => 'Text',
);static $has_one = array(
'ProductPage' => 'ProductPage',
);static $field_names = array(
'Attribute' => 'Attribute',
'Value' => 'Value',
);function getCMSFields_forPopup() {
$fields = new FieldSet();$attributes = DataObject::get('ProductHolderAttribute');
if ($attributes) {
$attributes = $attributes->toDropdownMap('Title', 'Title', '(Select one)', true);
}$fields->push(new DropdownField('Attribute', 'Attribute', $attributes));
$fields->push(new TextField('Value', 'Value'));return $fields;
}
}In the page:
function getCMSFields() {
$fields = parent::getCMSFields();
$attributetable = new ComplexTableField(
$this,
'ProductAttributes', // relation name
'ProductAttribute', // object class
ProductAttribute::$field_names, // fields to show in table
ProductAttribute::getCMSFields_forPopup(), // form that pops up for edit
"ProductPageID = {$this->ID}", // a filter to only display item associated with this page
);
$fields->addFieldToTab('Root.Content.Specifications', $attributetable);
return $fields;
}
| 975 Views | ||
|
Page:
1
|
Go to Top |


