/**
  * Returns the input fields for this widget.
  * 
  * @param Widget $widget       Widget to initialize
  * @param array  $fetchMethods Optional list of product fetch methods
  * 
  * @return FieldList
  * 
  * @author Sebastian Diel <*****@*****.**>
  * @since 13.03.2014
  */
 public static function getCMSFieldsForProductSliderWidget(Widget $widget, $fetchMethods = array())
 {
     if (empty($fetchMethods)) {
         $fetchMethods = array('random' => $widget->fieldLabel('fetchMethodRandom'), 'sortOrderAsc' => $widget->fieldLabel('fetchMethodSortOrderAsc'), 'sortOrderDesc' => $widget->fieldLabel('fetchMethodSortOrderDesc'));
     }
     $fields = SilvercartDataObject::getCMSFields($widget, 'ExtraCssClasses', false);
     $productGroupDropdown = new TreeDropdownField('SilvercartProductGroupPageID', $widget->fieldLabel('SilvercartProductGroupPage'), 'SiteTree');
     $productGroupDropdown->setTreeBaseID(SilvercartTools::PageByIdentifierCode('SilvercartProductGroupHolder')->ID);
     $toggleFields = array($fields->dataFieldByName('numberOfProductsToShow'), $fields->dataFieldByName('numberOfProductsToFetch'), $fields->dataFieldByName('fetchMethod'), SilvercartGroupViewHandler::getGroupViewDropdownField('GroupView', $widget->fieldLabel('GroupView'), $widget->GroupView));
     $fields->dataFieldByName('fetchMethod')->setSource($fetchMethods);
     $fields->dataFieldByName('numberOfProductsToShow')->setDescription($widget->fieldLabel('numberOfProductsToShowInfo'));
     $fields->dataFieldByName('isContentView')->setDescription($widget->fieldLabel('isContentViewInfo'));
     if (is_object($fields->dataFieldByName('useSelectionMethod'))) {
         $fields->dataFieldByName('useSelectionMethod')->setSource(array('productGroup' => $widget->fieldLabel('SelectionMethodProductGroup'), 'products' => $widget->fieldLabel('SelectionMethodProducts')));
         $toggleFields[] = $fields->dataFieldByName('useSelectionMethod');
         $productGroupDropdown->setDescription($widget->fieldLabel('SilvercartProductGroupPageDescription'));
     }
     $toggleFields[] = $productGroupDropdown;
     $productDataToggle = ToggleCompositeField::create('ProductDataToggle', $widget->fieldLabel('ProductDataToggle'), $toggleFields)->setHeadingLevel(4);
     $productRelationToggle = ToggleCompositeField::create('ProductRelationToggle', $widget->fieldLabel('ProductRelationToggle'), array($fields->dataFieldByName('SilvercartProducts')))->setHeadingLevel(4);
     $fields->removeByName('numberOfProductsToShow');
     $fields->removeByName('numberOfProductsToFetch');
     $fields->removeByName('fetchMethod');
     $fields->removeByName('useSelectionMethod');
     $fields->removeByName('SilvercartProducts');
     $fields->addFieldToTab("Root.Main", $productDataToggle);
     $fields->addFieldToTab("Root.Main", $productRelationToggle);
     $widget->getCMSFieldsSliderTab($fields);
     //$widget->getCMSFieldsRoundaboutTab($fields);
     return $fields;
 }
示例#2
0
 /**
  * Add fields to manage FAQs.
  *
  * @return $fields
  */
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $this->extend('beforeGetCMSFields', $fields);
     // setup category dropdown field
     $taxonomyRoot = self::getRootCategory();
     $categoryField = new TreeDropdownField('CategoryID', 'Category', 'TaxonomyTerm', 'ID', 'Name');
     //change this to 0 if you want the root category to show
     $categoryField->setTreeBaseID($taxonomyRoot->ID);
     $categoryField->setDescription(sprintf('Select one <a href="admin/taxonomy/TaxonomyTerm/EditForm/field/TaxonomyTerm/item/%d/#Root_Children">' . 'FAQ Category</a>', $taxonomyRoot->ID));
     $fields->addFieldToTab('Root.Main', $categoryField);
     $this->extend('updateGetCMSFields', $fields);
     return $fields;
 }