Skip to content

Commit

Permalink
Merge pull request #252 from ElectricMaxxx/seo-extra-properties
Browse files Browse the repository at this point in the history
[WIP] add custom property example, fix location to en
  • Loading branch information
dbu committed Apr 18, 2014
2 parents a8177de + 2f8ea5e commit d9f7dba
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/tests/HomepageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function testContents()
$this->assertCount(1, $crawler->filter('h1:contains(Homepage)'));
$this->assertCount(1, $crawler->filter('h2:contains("Welcome to the Symfony CMF Demo")'));

$menuCount = $this->isSearchSupported() ? 19 : 18;
$menuCount = $this->isSearchSupported() ? 20 : 19;
$this->assertCount($menuCount, $crawler->filter('ul.menu_main li'));
}

Expand Down
2 changes: 1 addition & 1 deletion src/Sandbox/MainBundle/DataFixtures/PHPCR/LoadMenuData.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function load(ObjectManager $dm)
$seo = $this->createMenuNode($dm, $main, 'seo', array('SEO'), $dm->find(null, "$content_path/simple-seo-example"));
$this->createMenuNode($dm, $seo, 'simple-seo-example', array('en' => 'Seo-Simple-Content'), $dm->find(null, "$content_path/simple-seo-example"));
$this->createMenuNode($dm, $seo, 'demo-seo-extractor', array('en' => 'Seo-Extractor'), $dm->find(null, "$content_path/demo-seo-extractor"));

$this->createMenuNode($dm, $seo, 'simple-seo-property', array('en' => 'Seo-Extra-Properties'), $dm->find(null, "$content_path/simple-seo-property"));
$dm->flush();
}

Expand Down
5 changes: 5 additions & 0 deletions src/Sandbox/MainBundle/DataFixtures/PHPCR/LoadRoutingData.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ public function load(ObjectManager $dm)
$seo->setContent($dm->find(null, "$content_path/simple-seo-example"));
$dm->persist($seo);

$seo = new Route();
$seo->setPosition($home, 'simple-seo-property');
$seo->setContent($dm->find(null, "$content_path/simple-seo-property"));
$dm->persist($seo);

$seo = new Route();
$seo->setPosition($home, 'demo-seo-extractor');
$seo->setContent($dm->find(null, "$content_path/demo-seo-extractor"));
Expand Down
31 changes: 31 additions & 0 deletions src/Sandbox/MainBundle/DataFixtures/PHPCR/LoadStaticPageData.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
use PHPCR\Util\NodeHelper;

use Sandbox\MainBundle\Document\DemoSeoContent;
use Symfony\Cmf\Bundle\SeoBundle\Model\ExtraProperty;
use Symfony\Cmf\Bundle\SeoBundle\SeoAwareInterface;
use Symfony\Cmf\Bundle\SeoBundle\SeoMetadata;
use Symfony\Component\DependencyInjection\ContainerAware;
use Symfony\Component\Yaml\Parser;
Expand Down Expand Up @@ -50,6 +52,7 @@ public function load(ObjectManager $manager)
foreach ($overview['title'] as $locale => $title) {
$page->setTitle($title);
$page->setBody($overview['body'][$locale]);

$manager->bindTranslation($page, $locale);
}
} else {
Expand Down Expand Up @@ -93,8 +96,36 @@ public function load(ObjectManager $manager)
$seoMetadata->setMetaDescription('This is a simple example of an seo aware document in the sandbox.');
$seoMetadata->setMetaKeywords('Seo');
$seoDemo->setSeoMetadata($seoMetadata);

$manager->persist($seoDemo);
$manager->bindTranslation($seoDemo, 'en');

//add a loading for a simple seo aware page
$seoDemo = new DemoSeoContent();
$seoDemo->setName('simple-seo-property');
$seoDemo->setTitle('Simple seo property');
$seoDemo->setBody(
'<p>
SeoMetadata have got the possibility to
to add custom properties for custom
meta tags. You just to set a type, key
and value
</p>'
);
$seoDemo->setParentDocument($parent);

$seoMetadata = new SeoMetadata();
$seoMetadata->setTitle('Simple seo property');
$seoMetadata->setMetaKeywords('Seo, Properties');
$seoMetadata->addExtraProperty(new ExtraProperty('content-type','text/html', 'http-equiv'));
$seoMetadata->addExtraProperty(new ExtraProperty('robots','index, follow', 'name'));
$seoMetadata->addExtraProperty(new ExtraProperty('og:title','extra title', 'property'));
$seoDemo->setSeoMetadata($seoMetadata);
$manager->persist($seoDemo);

$manager->bindTranslation($seoDemo, 'en');


$manager->flush(); //to get ref id populated
}

Expand Down
6 changes: 6 additions & 0 deletions src/Sandbox/MainBundle/Resources/data/page.yml
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ static:
title:
en: Demo - Seo extractors
fr: Demo - Seo extractors
de: Demo - Seo extractors
body:
en: |
This example uses extractors to get the SeoMetadata.
Expand All @@ -181,3 +182,8 @@ static:
Needs to be translated:
This example uses extractors to get the SeoMetadata.
Extractor try to extract the title, description, keywords and original url from the document.
de: |
Dieses Beispiel benutzt die sog. Extractors
um die SeoMetada direct vom content zu bekommen.
Title, Description, Keywords und die originale url
können einfach ausgelesen werden.

0 comments on commit d9f7dba

Please sign in to comment.