/** * 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; }
/** * 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; }
/** * Adds dropdown field for album folders (subfolders inside assets/cwsoft-foldergallery) * * @return modified backend fields */ function getCMSFields() { // create folder assets/cwsoft-foldergallery if not already exists Folder::find_or_make('cwsoft-foldergallery'); // get default CMS fields $fields = parent::getCMSFields(); // get "cwsoft-foldergallery" folder object $album = Folder::get()->filter('Filename', 'assets/cwsoft-foldergallery/')->First(); if (!$album) { return $fields; } // add dropdown field with album folders (subfolders of assets/cwsoft-foldergallery) $tree = new TreeDropdownField('AlbumFolderID', _t('cwsFolderGalleryPage.CHOOSE_IMAGE_FOLDER', 'Choose image folder (subfolder assets/cwsoft-foldergallery/)'), 'Folder'); $tree->setTreeBaseID((int) $album->ID); $fields->addFieldToTab('Root.Main', $tree, 'Content'); return $fields; }
/** * Adds the fields for the MirrorProductGroups tab * * @param FieldList $fields FieldList to add fields to * * @return void */ public function getFieldsForProductGroups($fields) { $productGroupHolder = SilvercartTools::PageByIdentifierCode('SilvercartProductGroupHolder'); $silvercartProductGroupDropdown = new TreeDropdownField('SilvercartProductGroupID', $this->fieldLabel('SilvercartProductGroup'), 'SiteTree'); if ($productGroupHolder) { $productGroupHolderID = $productGroupHolder->ID; } else { $productGroupHolderID = 0; } $silvercartProductGroupDropdown->setTreeBaseID($productGroupHolderID); if ($this->exists()) { $silvercartProductGroupMirrorPagesField = new TreeMultiselectField('SilvercartProductGroupMirrorPages', $this->fieldLabel('SilvercartProductGroupMirrorPages'), 'SiteTree'); $silvercartProductGroupMirrorPagesField->setTreeBaseID($productGroupHolderID); $fields->removeByName('SilvercartProductGroupMirrorPages'); $fields->insertBefore($silvercartProductGroupDropdown, 'ProductNumberGroup'); $fields->insertAfter($silvercartProductGroupMirrorPagesField, 'SilvercartProductGroupID'); } else { $fields->insertBefore($silvercartProductGroupDropdown, 'ProductNumberGroup'); } }
/** * Returns the form used to create new pages. If the current form is not set * (ie the user is NOT currently editing), then we just return null. * * @return Form */ public function CreatePageForm() { $createOptions = array('child' => 'As a child of the selected page', 'sibling' => 'As a sibling of the selected page'); $pageTree = new TreeDropdownField('CreateContext', _t('WikiPage.CREATE_CONTEXT', 'Select an existing page'), 'WikiPage'); $pageTree->setValue($this->ID); $pageTree->setTreeBaseID($this->data()->getWikiRoot()->ID); $fields = FieldList::create(new TextField('NewPageName', _t('WikiPage.NEW_PAGE_NAME', 'New Page Name')), $pageTree, new OptionsetField('CreateType', _t('WikiPage.CREATE_OPTIONS', 'and create the new page '), $createOptions, 'child')); $actions = FieldList::create(new FormAction('addpage', _t('WikiPage.ADD_PAGE', 'Create'))); return new Form($this, 'CreatePageForm', $fields, $actions); }
/** * Return all fields of the backend. * * @return FieldList Fields of the CMS */ public function getCMSFields() { $fields = parent::getCMSFields(); $useOnlydefaultGroupviewSource = array('inherit' => _t('SilvercartProductGroupPage.DEFAULTGROUPVIEW_DEFAULT'), 'yes' => $this->fieldLabel('Yes'), 'no' => $this->fieldLabel('No')); $defaultGroupViewField = SilvercartGroupViewHandler::getGroupViewDropdownField('DefaultGroupView', $this->fieldLabel('DefaultGroupView'), $this->DefaultGroupView, _t('SilvercartProductGroupPage.DEFAULTGROUPVIEW_DEFAULT')); $useOnlyDefaultGroupViewField = new DropdownField('UseOnlyDefaultGroupView', $this->fieldLabel('UseOnlyDefaultGroupView'), $useOnlydefaultGroupviewSource, $this->UseOnlyDefaultGroupView); $productGroupsPerPageField = new TextField('productGroupsPerPage', $this->fieldLabel('productGroupsPerPage')); $defaultGroupHolderViewField = SilvercartGroupViewHandler::getGroupViewDropdownField('DefaultGroupHolderView', $this->fieldLabel('DefaultGroupHolderView'), $this->DefaultGroupHolderView, $this->fieldLabel('DefaultGroupView')); $useOnlyDefaultGroupHolderViewField = new DropdownField('UseOnlyDefaultGroupHolderView', $this->fieldLabel('UseOnlyDefaultGroupHolderView'), $useOnlydefaultGroupviewSource, $this->UseOnlyDefaultGroupHolderView); $fieldGroup = new SilvercartFieldGroup('FieldGroup', '', $fields); $redirectionFieldGroup = new SilvercartFieldGroup('RedirectionFieldGroup', '', $fields); $redirectToProductGroupField = new CheckboxField('RedirectToProductGroup', $this->fieldLabel('RedirectToProductGroup')); $linkToField = new TreeDropdownField('LinkToID', $this->fieldLabel('LinkTo'), 'SiteTree'); $productGroupsPerPageField->setRightTitle(_t('SilvercartProductGroupPage.PRODUCTSPERPAGEHINT')); $fieldGroup->push($defaultGroupViewField); $fieldGroup->push($useOnlyDefaultGroupViewField); $fieldGroup->breakAndPush($productGroupsPerPageField); $fieldGroup->breakAndPush($defaultGroupHolderViewField); $fieldGroup->push($useOnlyDefaultGroupHolderViewField); $redirectionFieldGroup->push($redirectToProductGroupField); if ($this->exists()) { $linkToField->setTreeBaseID($this->ID); $redirectionFieldGroup->breakAndPush($linkToField); } $displaySettingsToggle = ToggleCompositeField::create('DisplaySettingsToggle', $this->fieldLabel('DisplaySettings'), array($fieldGroup))->setHeadingLevel(4)->setStartClosed(true); $redirectionSettingsToggle = ToggleCompositeField::create('RedirectionSettingsToggle', $this->fieldLabel('RedirectionSettings'), array($redirectionFieldGroup))->setHeadingLevel(4)->setStartClosed(true); $fields->insertAfter($redirectionSettingsToggle, 'Content'); $fields->insertAfter($displaySettingsToggle, 'Content'); $this->extend('extendCMSFields', $fields); return $fields; }