当前位置: 首页>>代码示例>>PHP>>正文


PHP FieldList::addFIeldToTab方法代码示例

本文整理汇总了PHP中FieldList::addFIeldToTab方法的典型用法代码示例。如果您正苦于以下问题:PHP FieldList::addFIeldToTab方法的具体用法?PHP FieldList::addFIeldToTab怎么用?PHP FieldList::addFIeldToTab使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FieldList的用法示例。


在下文中一共展示了FieldList::addFIeldToTab方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: updateCMSFields

 /**
  * updateCMSFields.
  * Update Silverstripe CMS Fields for SEO Module
  *
  * @param FieldList
  * @return none
  */
 public function updateCMSFields(FieldList $fields)
 {
     // exclude SEO tab from some pages
     if (in_array($this->owner->getClassName(), Config::inst()->get("SeoSiteTreeExtension", "excluded_page_types"))) {
         return;
     }
     Requirements::css(SEO_DIR . '/css/seo.css');
     //Requirements::javascript(SEO_DIR.'/javascript/seo.js');
     // Get title template
     $sc = SiteConfig::current_site_config();
     if ($sc->SEOTitleTemplate) {
         $TitleTemplate = $sc->SEOTitleTemplate;
     } else {
         $TitleTemplate = "page_title + ' » ' + siteconfig_title";
     }
     $jsvars = array("TitleTemplate" => $TitleTemplate);
     // check if the page being checked provides images and links information
     $providedInfoFIeld = null;
     $class = new ReflectionClass($this->owner);
     if ($class->implementsInterface('SeoInformationProvider')) {
         $links = $this->owner->getLinksForSeo();
         $images = $this->owner->getImagesForSeo();
         // if we have images or links add an extra div containing info in data attributes
         $info = array();
         if (sizeof($links) > 0) {
             $info['data-has-links'] = true;
         }
         if (sizeof($images) > 0) {
             $info['data-has-images'] = true;
         }
         if (sizeof($info) > 0) {
             $html = '<div id="providedInfo" ';
             foreach ($info as $key => $val) {
                 $html .= $key . '=' . $val;
             }
             $html .= ">INFO HERE</div>";
             $providedInfoFIeld = new LiteralField('ProvidedSEOInfo', $html);
         }
     }
     Requirements::javascriptTemplate(SEO_DIR . '/javascript/seo.js', $jsvars);
     // lets create a new tab on top
     $fields->addFieldsToTab('Root.SEO', array(LiteralField::create('googlesearchsnippetintro', '<h3>' . _t('SEO.SEOGoogleSearchPreviewTitle', 'Preview google search') . '</h3>'), LiteralField::create('googlesearchsnippet', '<div id="google_search_snippet"></div>'), LiteralField::create('siteconfigtitle', '<div id="ss_siteconfig_title">' . $this->owner->getSiteConfig()->Title . '</div>')));
     // move Metadata field from Root.Main to SEO tab for visualising direct impact on search result
     $fields->removeByName('Metadata');
     // Create SEO tabs
     $fields->addFieldToTab("Root.SEO", new TabSet('Options'));
     $fields->findOrMakeTab('Root.SEO.Options.HelpAndSEOScore', _t('SEO.SEOScoreAndTips', 'SEO Score and Tips'));
     $fields->findOrMakeTab('Root.SEO.Options.Meta', _t('SEO.SEOMetaData', 'Metadata'));
     $fields->findOrMakeTab('Root.SEO.Options.Social', _t('SEO.Social', 'Social'));
     $fields->findOrMakeTab('Root.SEO.Options.Advanced', _t('SEO.Advanced', 'Advanced'));
     if ($providedInfoFIeld) {
         $fields->addFIeldToTab('Root.SEO', $providedInfoFIeld);
     }
     // ADD metadata fields
     $fields->addFieldsToTab('Root.SEO.Options.Meta', array(TextField::create("MetaTitle", _t('SEO.SEOMetaTitle', 'Meta title'))->setRightTitle(_t('SEO.SEOMetaTitleHelp', 'Name of the page, search engines use this as title of search results. If unset, the page title will be used.')), TextareaField::create("MetaDescription", $this->owner->fieldLabel('MetaDescription'))->setRightTitle(_t('SiteTree.METADESCHELP', "Search engines use this content for displaying search results (although it will not influence their ranking)."))->addExtraClass('help'), TextareaField::create("ExtraMeta", $this->owner->fieldLabel('ExtraMeta'))->setRightTitle(_t('SiteTree.METAEXTRAHELP', "HTML tags for additional meta information. For example &lt;meta name=\"customName\" content=\"your custom content here\" /&gt;"))->addExtraClass('help')));
     // ADD SEOTIPS fiels
     //		$template = new SSViewer('Footer');
     //		$seotips = $template->process($this->owner->customise(new ArrayData(array(
     //			'ShowError' => true,
     //		))));
     //Debug::dump( SSViewer::get_theme_folder() );
     //		$pagehtml = $this->owner->renderwith(array('Footer'));
     $fields->addFieldsToTab('Root.SEO.Options.HelpAndSEOScore', array(LiteralField::create('ScoreTitle', '<h4 class="seo_score">' . _t('SEO.SEOScore', 'SEO Score') . '</h4>'), LiteralField::create('Score', $this->getHTMLStars()), HiddenField::create('SEOPageScore', $this->owner->SEOPageScore), LiteralField::create('ScoreClear', '<div class="score_clear"></div>'), GoogleSuggestField::create("SEOPageSubject", _t('SEO.SEOPageSubjectTitle', 'Subject of this page (required to view this page SEO score)'))));
     // ADD PageSubjectchecks if subject = defined
     //		if (!empty($this->SEOPageSubject)) {
     $fields->addFieldsToTab('Root.SEO.Options.HelpAndSEOScore', array(LiteralField::create('SimplePageSubjectCheckValues', $this->getHTMLSimplePageSubjectTest())));
     //		}
     // Add SEO score tips if below 10 -> add always, show/hide from js.
     //if ($this->seo_score < 10) {
     $fields->addFieldsToTab('Root.SEO.Options.HelpAndSEOScore', array(LiteralField::create('ScoreTipsTitle', '<h4 class="seo_score">' . _t('SEO.SEOScoreTips', 'SEO Score Tips') . '</h4>'), LiteralField::create('ScoreTips', $this->getSEOScoreTipsUL())));
     //}
     $fields->addFieldsToTab('Root.SEO.Options.Social', array(TextField::create("SEOFBdescription", _t('SEO.SEOFBdescription', 'Facebook description'))->setRightTitle(_t('SEO.SEOFBdescriptionHelp', 'Wanneer je niet de metabeschrijving wil gebruiken voor het delen van berichten op Facebook, maar een andere omschrijving wil, schrijf het dan hier.')), TextField::create("SEOFBAuthorlink", _t('SEO.SEOFBAuthorlink', 'Facebook author'))->setRightTitle(_t('SEO.SEOFBAuthorlinkHelp', 'Author Facebook PROFILE URL (incl. http://)')), TextField::create("SEOFBPublisherlink", _t('SEO.SEOFBPublisherlink', 'Facebook publisher'))->setRightTitle(_t('SEO.SEOFBPublisherlinkHelp', 'Publisher Facebook PAGE URL (incl. http://)')), TextField::create("SEOGplusAuthorlink", _t('SEO.SEOGplusAuthorlink', 'Google+ author'))->setRightTitle(_t('SEO.SEOGplusAuthorlinkHelp', 'Author Google+ PROFILE URL (incl. http://)')), TextField::create("SEOGplusPublisherlink", _t('SEO.SEOGplusPublisherlink', 'Google+ publisher'))->setRightTitle(_t('SEO.SEOGplusPublisherlinkHelp', 'Publisher Google+ PAGE URL (incl. http://)'))));
     $fields->addFieldsToTab('Root.SEO.Options.Advanced', array(HeaderField::create('RobotsTitle', _t('SEO.SEORobotSettings', 'Page settings for search engines'), 4), CheckboxField::create('MetaRobotsNoIndex', _t('SEO.MetaRobotsNoIndex', 'Prevent indexing this page')), CheckboxField::create('MetaRobotsNoFollow', _t('SEO.MetaRobotsNoFollow', 'Prevent following any links from this page')), CheckboxField::create('MetaRobotsNoCache', _t('SEO.MetaRobotsNoCache', 'Prevent caching a version of this page')), CheckboxField::create('MetaRobotsNoSnippet', _t('SEO.MetaRobotsNoSnippet', 'Prevent showing a snippet of this page in the search results (also prevents caching)'))));
 }
开发者ID:micschk,项目名称:silverstripe-liveseo,代码行数:81,代码来源:SeoSiteTreeExtension.php


注:本文中的FieldList::addFIeldToTab方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。