Jump to content

Integration with Twitter Cards


Morrigan

Recommended Posts

I recommended it too a while ago. Makes perfect sense to support these Twitter meta tags along with the ones Facebook looks for. Tweets with images are so much more likely to get clicks than just plain links. 

If you can’t wait: it’s surprisingly simple to add it to certain templates. For example, I added this to my video database in Pages:

{{\IPS\Output::i()->metaTags['twitter:card'] = 'summary_large_image';}}
{{\IPS\Output::i()->metaTags['twitter:site'] = '@TypographyGuru';}}
{{\IPS\Output::i()->metaTags['twitter:title'] = $record->_title;}}
{{\IPS\Output::i()->metaTags['twitter:description'] = 'Watch this video in the collection of the best typography videos on Typography.Guru';}}
{{\IPS\Output::i()->metaTags['twitter:image'] = (string) \IPS\File::get( 'cms_Records', $record->record_image )->url;}}

 

Link to comment
Share on other sites

  • 4 months later...

Hi, I have been searching this site for something similar and this post came up.

Does anyone know if this went anywhere? 

Currently when a link to the sate gets tweeted the image shared is the one of my site logo.  I would like this to first check the thread/blog/article that is being shared and if no image if found then use the site logo.

Is this possible? 
Thanks

Link to comment
Share on other sites

  • 2 weeks later...
  • 3 months later...
On 2016-09-08 at 9:52 PM, steadyoptions said:

It is my understanding that IPS currently doesn't support it.

Question: if I want to implement it on article pages, which template should I put it to? Also, why the code above different from the sample code supplied by Twitter here?

¨Same! Where to implent it?

Link to comment
Share on other sites

On 9/8/2016 at 9:52 PM, steadyoptions said:

Question: if I want to implement it on article pages, which template should I put it to?

In the Pages template your database uses for the “record view”. 

On 9/8/2016 at 9:52 PM, steadyoptions said:

Also, why the code above different from the sample code supplied by Twitter here?

It isn’t. It’s an application of the Twitter code. You can’t just paste the Twitter code. It’s just an example. The fields need to be populated with the dynamic content from the database record. Also, don’t just copy my code above. That’s also just an example. 

My Pages template include Twitter card support. You don’t need to do anything else than add your Twitter handle to the template. 

 

Link to comment
Share on other sites

  • 3 months later...
On 28/04/2016 at 3:44 PM, opentype said:

I recommended it too a while ago. Makes perfect sense to support these Twitter meta tags along with the ones Facebook looks for. Tweets with images are so much more likely to get clicks than just plain links. 

If you can’t wait: it’s surprisingly simple to add it to certain templates. For example, I added this to my video database in Pages:


{{\IPS\Output::i()->metaTags['twitter:card'] = 'summary_large_image';}}
{{\IPS\Output::i()->metaTags['twitter:site'] = '@TypographyGuru';}}
{{\IPS\Output::i()->metaTags['twitter:title'] = $record->_title;}}
{{\IPS\Output::i()->metaTags['twitter:description'] = 'Watch this video in the collection of the best typography videos on Typography.Guru';}}
{{\IPS\Output::i()->metaTags['twitter:image'] = (string) \IPS\File::get( 'cms_Records', $record->record_image )->url;}}

 

Perfect!

Link to comment
Share on other sites

  • 2 weeks later...
On 28/04/2016 at 3:44 PM, opentype said:

{{\IPS\Output::i()->metaTags['twitter:image'] = (string) \IPS\File::get( 'cms_Records', $record->record_image )->url;}}

Is there a way to mix text and strings?

I want to output record's description mixing a common description text and with strings: record title and database category name.

And is there an easy way to use tags as keywords?

Link to comment
Share on other sites

  • 1 month later...
On 2016-12-15 at 7:56 PM, opentype said:

In the Pages template your database uses for the “record view”. 

It isn’t. It’s an application of the Twitter code. You can’t just paste the Twitter code. It’s just an example. The fields need to be populated with the dynamic content from the database record. Also, don’t just copy my code above. That’s also just an example. 

My Pages template include Twitter card support. You don’t need to do anything else than add your Twitter handle to the template. 

 

Does your Supergrid view forumposts the same as grid?

Link to comment
Share on other sites

7 hours ago, Joel R said:

To clarify, the Supergrid template by @opentype only applies to records / articles created in IP.Pages.  It does not change the layout of IP.Board posts or topics.  

Okay thanks. That's what I needed to know. Is there anything that works the same as grid but applies to forums?

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...