Version

Documentation » Seo

6. Sitemap »

« 4. Breadcrumb

5. Social blocks

You can use social blocks by adding them in your config. You must install SonataBlockBundle as it is required to render block services.

# config/packages/sonata_block.yaml

sonata_block:
    sonata.seo.block.social.container:
    sonata.seo.block.email.share_button:
    sonata.seo.block.facebook.like_box:
    sonata.seo.block.facebook.like_button:
    sonata.seo.block.facebook.send_button:
    sonata.seo.block.facebook.share_button:
    sonata.seo.block.twitter.share_button:
    sonata.seo.block.twitter.follow_button:
    sonata.seo.block.twitter.hashtag_button:
    sonata.seo.block.twitter.mention_button:
    sonata.seo.block.twitter.embed:
    sonata.seo.block.pinterest.pin_button:

The SocialBlockContainer overrides the PageBundle’s default container to render the social blocks in a dedicated template, in order to have them properly aligned on a page.

These blocks render the correct HTML code to display social widgets but you need to include the related SDK in your main layout. You can include them by including these templates:

{% include '@SonataSeo/Block/_facebook_sdk.html.twig' %}

{% include '@SonataSeo/Block/_twitter_sdk.html.twig' %}

{% include '@SonataSeo/Block/_pinterest_sdk.html.twig' %}

Check the related documentation to get more details :

5.1. Twitter Embed Tweet

The sonata.seo.block.twitter.embed allows you to embed a tweet by giving its id, URL or embed content. Please refer to Embedded Tweets doc and OEmbed API doc for a full understanding.

The block service allows you to ask the API if you’ve given an ID or a URL .

You’ll need to install a psr/http-client (e.g. symfony/http-client) and a psr/http-message (e.g nyholm/psr7) to request the Twitter API:

composer require symfony/http-client nyholm/psr7

Found a typo? Something is wrong in this documentation? Just fork and edit it!