Skip to content

Yii Tutorial :: How to Add Facebook Open Graph Tags ?

Last updated on February 10, 2018

This Blog post is about Adding Facebook Open Graph Tags to the web app in Yii, This is really simple Task, Using This Tags We can tell Facebook What Content Should share like Image, Title, Description .. etc.

Syntax


Yii::app()->clientScript->registerMetaTag("TagValue", null, null, array('property' => "og:TagName"));

How to Use

    Yii::app()->clientScript->registerMetaTag("", null, null, array('property' => "og:image"));
    Yii::app()->clientScript->registerMetaTag("", null, null, array('property' => "og:title"));
    Yii::app()->clientScript->registerMetaTag("", null, array('property' => "og:url"));
    Yii::app()->clientScript->registerMetaTag("", null, null, array('property' => "og:site_name"));
    Yii::app()->clientScript->registerMetaTag("", null, null, array('property' => "og:type"));

You can place Above lines in views Files or in you Controller File

Reference Page : http://developers.facebook.com/docs/opengraphprotocol/

and

http://www.yiiframework.com/doc/api/1.1/CClientScript

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments