[READ-ONLY] Subtree split of the Kunstmaan SeoBundle -- master at Kunstmaan/KunstmaanBundlesCMS
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
Controller Merge pull request #1341 from dannyvw/fix/flash Nov 2, 2016
Helper Replace deprecated SecurityContext service Jan 13, 2016
Repository Implement default Seo functionality for nodes Oct 19, 2012
Resources [SeoBundle] Catch exception when OG image no longer exists Oct 10, 2016
Twig [SeoBundle] Catch exception when OG image no longer exists Oct 10, 2016
.gitignore Implement default Seo functionality for nodes Oct 19, 2012
.travis.yml [Travis]: remove php 7 from allowed failures Feb 9, 2016
LICENSE Implement default Seo functionality for nodes Oct 19, 2012
README.md Files should not be executable Sep 19, 2014
build.xml Implement default Seo functionality for nodes Oct 19, 2012
composer.json Composer updates after 3.5 release Feb 15, 2016
phpunit.xml.dist Implement default Seo functionality for nodes Oct 19, 2012



Build Status Total Downloads Latest Stable Version Analytics

Annotating content with metadata for social sharing and seo purposes cannot be overlooked nowadays. The KunstmaanSeoBundle contains default editing functionality for OpenGraph data, meta descriptions, keywords and titles and Metriweb tags. Because the metatagging and tracking options are always changing, a free field to add custom header information is provided as well.


View more screenshots and information http://bundles.kunstmaan.be.


This bundle is compatible with all Symfony 2.3.* releases. More information about installing can be found in this line by line walkthrough of installing Symfony and all our bundles, please refer to the Getting Started guide and enjoy the full blown experience.

Symfony 2.2

If you want to use this bundle for a Symfony 2.2 release, use the 2.2 branch.



In your template define the following to import all SEO metadata. This SEO metadata is set in the SEO tab for your page in the backend.

    {% if page is defined %}
        {{ render_seo_metadata_for(page) }}
    {% endif %}

For the title there are several options. There are several twig functions which return a title based on which is found first. If they are all null or empty it'll return an empty string.

The get_title_for twig function used the following order:

  • SEO title
  • Page title If nothing is set it'll return an empty string.

Another option is get_title_for_page_or_default. This twig function accepts a default string that is used as a fallback.

  • SEO title
  • default string
  • Page title

You can also access the raw SEO object through the get_seo_for function.

Social Widgets

And finally the SEO bundle is also capable of generating 'social widgets' such as a facebook like button. For now only facebook like & linkedin product are supported.

Use the get_social_widget_for function. Example: get_social_widget_for(page, 'linkedin').

You can override the views for all the functions that generate HTML output.

Google Analytics

Added to the SEO bundle are a few helpers to control Google Analytics.

These helpers rely on the inclusion of the analytics.js file that's provided in this bundle. The script itself relies on jQuery to be present.

    {% javascripts
        <script src='{{ asset_url }}'></script>
    {% endjavascripts %}

First up is google_analytics_initialize which looks for the Google Analytics Account ID in your config.

        google.analytics.account_id: 'UA-XXXXX-1'

You can also optionally pass the account_id as an argument to the function.

    {{ google_analytics_initialize({'account_id': 'UA-XXXXX-1'}) }}

This script will set up a queue with commands (_gaq) and the Google Analytics script itself (_ga). When Twig is in debug mode it'll not initialize the script but instead it'll just dump all requests to the console. This way you can easily monitor what Google Analytics is planning on doing in your production environment.

The script will automatically track downloads, external links, links to email addresses & button clicks.

Finally, we've also provided a JavaScript function which you'll have to call manually once the Twitter/Facebook SDK's have been loaded. This will then bind a callback via the SDKs which will log the events.

    googleAnalyticsApi.trackSocial('optional pageurl', 'optional trackername')

We've also added a helper for e-commerce tracking. You have to set up an Order object with its OrderItems and pass it along to the google_analytics_track_order twig function. This will output the correctly formatted syntax for Google Analytics.

    public function service(ContainerInterface $container, Request $request, RenderContext $renderContext)
        $order = (new Order())

        $order->orderItems[] = (new OrderItem())
            ->setName('ACME 3000 Starter Kit')
            ->setTaxes((20 * 13.5) * 0.21)
            ->setCategoryorVariation('World Domination')

        $order->orderItems[] = (new OrderItem())
            ->setName('Super Duper Kit')
            ->setTaxes((3000) * 0.21)

        $renderContext['order'] = $order;
    {{ google_analytics_track_order(order) }}