fond-of-spryker/open-graph

Implementation of the Facebook Open Graph protocol for Spryker

1.0.1 2018-10-18 07:38 UTC

This package is auto-updated.

Last update: 2022-05-05 14:34:23 UTC


README

Build Status PHP from Travis config license

A Basic implementation of the Facebook Open Graph protocol for Spryker

Installation

composer require fond-of-spryker/open-graph

1. Enable the Module in the configuration file

// ---------- Google Tag Manager
$config[OpenGraphConstants::ENABLED::ENABLED] = true;

2. Add Product Image Property Configurations in the configuration file

$config[OpenGraphConstants::PRODUCT_IMAGE_SET] = 'default';
$config[OpenGraphConstants::PRODUCT_IMAGE_URL_TYPE] = 'externalUrlLarge';

3. Add twig service provider to YvesBootstrap.php in registerServiceProviders()

$this->application->register(new OpenGraphTwigServiceProvider());

4. Add the Twig Extension in the neccessary Twig Templates

  Application/layout/layout.twig 
  between <head></head> tags
  
    {# Open Graph Protocol for Facebook and SEO #}
    {% block opengraph %}
        {% set params = {
            'title': 'global.shop.title' | trans,
            'description': '',
            'url': app.request.uri,
            'type': 'website',
            'site_name': app.locale | slice(0, 2)
        }
        %}
        {{ openGraph(params)}}
    {% endblock %}
  Catalog/catalog/index.twig 
  {% block opengraph %}
      {% set params = {
          'title': category.name,
          'description': '',
          'url': app.request.uri,
          'type': 'website',
          'site_name': '....'
      }
      %}
      {{ openGraph(params)}}
  {% endblock %}
  Product/product/detail.twig  
  {% block opengraph %}
      {% set params = {
          'title': product.name,
          'description': product.description,
          'url': app.request.uri,
          'type': 'product',
          'site_name': '...',
          'product': product
      }
      %}
      {{ openGraph(params)}}
  {% endblock %}