Skip to content

Commit

Permalink
Merge pull request #35 from gopalsareen/seo_health_and_grid_changes
Browse files Browse the repository at this point in the history
Render html using render() rather than file_get_contents etc
  • Loading branch information
zanderwar authored Mar 13, 2019
2 parents 5e577c2 + bbcc780 commit 9b5c2f0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
4 changes: 4 additions & 0 deletions _config/extensions.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
Name: silverstripe-seo
---

Page:
extensions:
- Vulcan\Seo\Extensions\PageHealthExtension
Expand Down
7 changes: 5 additions & 2 deletions src/Extensions/PageHealthExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Vulcan\Seo\Extensions;

use SilverStripe\CMS\Controllers\ModelAsController;
use SilverStripe\Control\Controller;
use SilverStripe\Core\ClassInfo;
use SilverStripe\Forms\FieldList;
use SilverStripe\Forms\TextField;
Expand Down Expand Up @@ -41,7 +43,7 @@ public function updateCMSFields(FieldList $fields)
}

$fields->addFieldsToTab('Root.Main', [
ToggleCompositeField::create(null, 'SEO Health Analysis', [
ToggleCompositeField::create('SEOHealthAnalysis', 'SEO Health Analysis', [
GoogleSearchPreview::create('GoogleSearchPreview', 'Search Preview', $this->getOwner(), $this->getRenderedHtmlDomParser()),
TextField::create('FocusKeyword', 'Set focus keyword'),
HealthAnalysisField::create('ContentAnalysis', 'Content Analysis', $this->getOwner()),
Expand All @@ -57,7 +59,8 @@ public function updateCMSFields(FieldList $fields)
public function getRenderedHtml()
{
if (!$this->renderedHtml) {
$this->renderedHtml = file_get_contents($this->getOwner()->AbsoluteLink().'?stage=Stage');
$controllerName = $this->owner->getControllerName();
$this->renderedHtml = $controllerName::singleton()->render($this->owner);
}

if ($this->renderedHtml === false) {
Expand Down
4 changes: 2 additions & 2 deletions src/Extensions/PageSeoExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,13 @@ public function updateCMSFields(FieldList $fields)
parent::updateCMSFields($fields);

$fields->addFieldsToTab('Root.Main', [
ToggleCompositeField::create(null, 'Facebook SEO', [
ToggleCompositeField::create('FacebookSeoComposite', 'Facebook SEO', [
DropdownField::create('FacebookPageType', 'Type', FacebookMetaGenerator::getValidTypes()),
TextField::create('FacebookPageTitle', 'Title')->setAttribute('placeholder', $this->getOwner()->Title)->setRightTitle('If blank, inherits default page title')->setTargetLength(45, 25, 70),
UploadField::create('FacebookPageImage', 'Image')->setRightTitle('Facebook recommends images to be 1200 x 630 pixels. If no image is provided, facebook will choose the first image that appears on the page which usually has bad results')->setFolderName('seo'),
TextareaField::create('FacebookPageDescription', 'Description')->setAttribute('placeholder', $this->getOwner()->MetaDescription ?: $this->getOwner()->dbObject('Content')->LimitCharacters(297))->setRightTitle('If blank, inherits meta description if it exists or gets the first 297 characters from content')->setTargetLength(200, 160, 320),
]),
ToggleCompositeField::create(null, 'Twitter SEO', [
ToggleCompositeField::create('TwitterSeoComposite', 'Twitter SEO', [
TextField::create('TwitterPageTitle', 'Title')->setAttribute('placeholder', $this->getOwner()->Title)->setRightTitle('If blank, inherits default page title')->setTargetLength(45, 25, 70),
UploadField::create('TwitterPageImage', 'Image')->setRightTitle('Must be at least 280x150 pixels')->setFolderName('seo'),
TextareaField::create('TwitterPageDescription', 'Description')->setAttribute('placeholder', $this->getOwner()->MetaDescription ?: $this->getOwner()->dbObject('Content')->LimitCharacters(297))->setRightTitle('If blank, inherits meta description if it exists or gets the first 297 characters from content')->setTargetLength(200, 160, 320),
Expand Down

0 comments on commit 9b5c2f0

Please sign in to comment.