2017 © Pedro Peláez
 

silverstripe-module silverstripe-opengraph

Automatically generates Open Graph data for a Silverstripe page.

image

studiothick/silverstripe-opengraph

Automatically generates Open Graph data for a Silverstripe page.

  • Wednesday, December 21, 2016
  • by StudioThick
  • Repository
  • 4 Watchers
  • 0 Stars
  • 1,284 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 1 Versions
  • 8 % Grown

The README.md

SilverStripe OpenGraph extension

This module is a work in progress. Bug reports or feature requests welcome., (*1)

This module adds a getOpenGraph method to the Page class to be used in templates. Calling $OpenGraph in a template will return a series of automatically generated tags corresponding to the standard open graph attributes., (*2)

  • og:title: from $Title
  • og:type: hardcoded to "website"
  • og:image: absolute URL. tries $HeroImage, $PostImage, $Image, then $FeaturedImage
  • og:image:width: width, as og:image
  • og:image:height: height, as og:image
  • og:url: absolute URL of page (Director::protocolAndHost() . $this->Link)
  • og:description: from $MetaDescription
  • og:locale: from i18n::get_locale()
  • og:site_name: from $SiteConfig.Title, (*3)

  • og:determiner: unused, (*4)

  • og:locale:alternate: unused
  • og:audio: unused
  • og:video: unused

All of the above can be overridden in Page.php or a given subclass according to the naming convention getOpenGraph_attribute, with og removed and :s replaced with spaces. For example, getOpenGraph_image_width()., (*5)

To override the image selection behaviour (for example, to return a static image, or to return a field that is not in the list that the extension searches for), simply implement getOpenGraphImage() to return a SilverStripe Image object., (*6)

Installation

Install via composer require studiothick/silverstripe-opengraph., (*7)

Usage

Example:, (*8)

<head>
    <title>$SiteConfig.Title | $Title</title>

    $OpenGraph

</head>

The Versions

21/12 2016

dev-master

9999999-dev http://github.com/StudioThick/silverstripe-opengraph

Automatically generates Open Graph data for a Silverstripe page.

  Sources   Download

MIT

The Requires

 

silverstripe opengraph