Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class ProductPage extends Page {
- private static $many_many = array(
- 'RelatedProducts' => 'Product'
- );
- public function getCMSFields() {
- $fields = parent::getCMSFields();
- $products = ProductPage::get()->exclude(array('ID' => $this->owner->ID));
- $gridField = new GridField('products', 'Related Products', $products);
- $gridField->getConfig()->addComponent(new GridFieldManyRelationHandler($this, 'RelatedProducts'));
- $fields->addFieldToTab('Root.RelatedProducts', $gridfield);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement