/** * 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("SeoObjectExtension", "excluded_page_types"))) { return; } Requirements::css(SEO_DIR . '/css/seo.css'); Requirements::javascript(SEO_DIR . '/javascript/seo.js'); // better do this below in some init method? : $this->getSEOScoreCalculation(); $this->setSEOScoreTipsUL(); // 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->removeFieldFromTab('Root.Main', 'Metadata'); /*$fields->addFieldToTab("Root.SEO", new TabSet('Options', new Tab('Metadata', _t('SEO.SEOMetaData', 'Meta Data')), new Tab('HelpAndSEOScore', _t('SEO.SEOHelpAndScore', 'Help and SEO Score')) ));*/ $fields->addFieldsToTab('Root.SEO', array(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 <meta name=\"customName\" content=\"your custom content here\" />"))->addExtraClass('help'))); $fields->addFieldsToTab('Root.SEO', array(GoogleSuggestField::create("SEOPageSubject", _t('SEO.SEOPageSubjectTitle', 'Subject of this page (required to view this page SEO score)')), LiteralField::create('', '<div class="message notice"><p>' . _t('SEO.SEOSaveNotice', "After making changes save this page to view the updated SEO score") . '</p></div>'), LiteralField::create('ScoreTitle', '<h4 class="seo_score">' . _t('SEO.SEOScore', 'SEO Score') . '</h4>'), LiteralField::create('Score', $this->getHTMLStars()), LiteralField::create('ScoreClear', '<div class="score_clear"></div>'))); if ($this->checkPageSubjectDefined()) { $fields->addFieldsToTab('Root.SEO', array(LiteralField::create('SimplePageSubjectCheckValues', $this->getHTMLSimplePageSubjectTest()))); } if ($this->seo_score < 12) { $fields->addFieldsToTab('Root.SEO', array(LiteralField::create('ScoreTipsTitle', '<h4 class="seo_score">' . _t('SEO.SEOScoreTips', 'SEO Score Tips') . '</h4>'), LiteralField::create('ScoreTips', $this->seo_score_tips))); } }
/** * 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 <meta name=\"customName\" content=\"your custom content here\" />"))->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)')))); }