Coder Social home page Coder Social logo

twitter-card-meta's Introduction

Total Downloads License Build Status

Silverstripe Twitter Card Module

Simple Module to add Twitter Cards to your site

Installation

Get the goodness just like so:

 composer require toastnz/twitter-card-meta

And ensure you have the following in the <head> of your template:

 $MetaTags

If you are not using $MetaTags, you can use the following template code:

  <% include TwitterCardMeta %>

Step 4: Profit

twitter-card-meta's People

Contributors

danaenz avatar permanentinc avatar danaetoast avatar

Stargazers

MinamiYODA avatar Peter Thaleikis avatar Naoto Yokoyama avatar Mick avatar Milan Jelicanin avatar Petar Simic avatar

Watchers

James Cloos avatar  avatar  avatar Peter Thaleikis avatar  avatar

twitter-card-meta's Issues

SiteTree config "create_default_pages" ignored.

Hello @danaenz,

I noticed an interesting behavior in one particular project. In the "mysite/_config/config.yml" I have got the following lines:

# We don't want the default pages
SiteTree:
  create_default_pages: false

to avoid the creation of the 'Home', 'About us' and 'Contact us' pages. This worked fine until recently. With the installation of the twitter card module this doesn't seem to work anymore. I traced it back until I was sure the twitter module is playing a role in this error.

I dropped the database and deleted all cache files before running dev/build. With the module the pages were created, without they weren't created (expected).

CMS and framework are both 3.3.3.

Can you or anyone else confirm this?

Cheers,
Peter

SilverStripe 3.4?

Hello,

I saw that the version 3.4.x versions of framework and CMS are excluded in the composer.json file. Is this still up to date? Are there any plans for supporting 3.4.x?

Cheers,
Peter

Remove "Site Handle" from the individual page and leave it to the Site Config

In reference to this conversation.

I also ran into a bug where TwitterCardType wasn't getting set.

The following patch fixes both:

diff --git twitter-card-meta/Extensions/TwitterCardMeta.php twitter-card-meta/Extensions/TwitterCardMeta.php
index e065f4d..52b5dc3 100644
--- twitter-card-meta/Extensions/TwitterCardMeta.php
+++ twitter-card-meta/Extensions/TwitterCardMeta.php
@@ -30,11 +30,12 @@ class TwitterCardMeta extends DataExtension {
      * @return Object
      */
     public function updateCMSFields(FieldList $fields) {
-
+        if (!$this->owner->TwitterCardType) {
+            $this->owner->TwitterCardType = 'summary_large_image';
+        }
         $fields->addFieldsToTab('Root.Main', ToggleCompositeField::create('Twitter Graph', 'Twitter Card',
             array(
                 LiteralField::create('', '<h2>&nbsp;&nbsp;&nbsp;Twitter Card <img style="position:relative;top:4px;left 4px;" src="' . Director::absoluteBaseURL() . 'twitter-card-meta/Images/twitter.png"></h2>'),
-                TextField::create('TwitterSite', 'Site Handle')->setAttribute('placeholder', 'e.g @sitename')->setRightTitle('Twitter account name for the site'),
                 TextField::create('TwitterCreator', 'Creator Handle')->setAttribute('placeholder', 'e.g @username')->setRightTitle('Twitter account name for the author/creator (Will default to site handle)'),
                 OptionsetField::create('TwitterCardType', 'Twitter Card Type', array(
                     'summary_large_image' => 'summary with large image',

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.