Version Notes
Initial version for Facebook Open Graph and Twitter Cards
Download this release
Release Info
Developer | Krish |
Extension | Jaljale_Social_Tags |
Version | 1.0.0 |
Comparing to | |
See all releases |
Version 1.0.0
- app/code/community/Jaljale/OpenGraph/Block/Index.php +88 -0
- app/code/community/Jaljale/OpenGraph/Helper/Data.php +5 -0
- app/code/community/Jaljale/OpenGraph/controllers/IndexController.php +22 -0
- app/code/community/Jaljale/OpenGraph/etc/adminhtml.xml +23 -0
- app/code/community/Jaljale/OpenGraph/etc/config.xml +49 -0
- app/code/community/Jaljale/OpenGraph/etc/system.xml +92 -0
- app/design/frontend/base/default/layout/opengraph.xml +12 -0
- app/design/frontend/base/default/template/opengraph/index.phtml +25 -0
- app/etc/modules/Jaljale_OpenGraph.xml +10 -0
- package.xml +20 -0
app/code/community/Jaljale/OpenGraph/Block/Index.php
ADDED
@@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Jaljale_OpenGraph_Block_Index extends Mage_Core_Block_Template{
|
3 |
+
|
4 |
+
public static $_store = '';
|
5 |
+
|
6 |
+
protected function _getStore()
|
7 |
+
{
|
8 |
+
if(self::$_store){
|
9 |
+
self::$_store = Mage::app()->getStore()->getStoreId();
|
10 |
+
}
|
11 |
+
|
12 |
+
return self::$_store;
|
13 |
+
}
|
14 |
+
public function getType()
|
15 |
+
{
|
16 |
+
if(Mage::registry('current_product'))
|
17 |
+
{
|
18 |
+
return "Product";
|
19 |
+
}
|
20 |
+
elseif(Mage::registry('current_category'))
|
21 |
+
{
|
22 |
+
return "Product Category";
|
23 |
+
}
|
24 |
+
else
|
25 |
+
{
|
26 |
+
return "Website";
|
27 |
+
}
|
28 |
+
}
|
29 |
+
public function getImage()
|
30 |
+
{
|
31 |
+
if(Mage::registry('current_product'))
|
32 |
+
{
|
33 |
+
return $this->helper('catalog/image')->init(Mage::registry('current_product'), 'small_image');
|
34 |
+
}
|
35 |
+
elseif(Mage::registry('current_category') && Mage::getModel('catalog/layer')->getCurrentCategory()->getThumbnail())
|
36 |
+
{
|
37 |
+
$categoryImage = Mage::getModel('catalog/layer')->getCurrentCategory()->getThumbnail();
|
38 |
+
return Mage::getBaseUrl('media')."catalog/category/".$categoryImage;
|
39 |
+
}
|
40 |
+
else
|
41 |
+
{
|
42 |
+
|
43 |
+
return Mage::getBaseUrl('media') . "jaljale/" . Mage::getStoreConfig('opengraph/common/image', $this->_getStore());
|
44 |
+
}
|
45 |
+
}
|
46 |
+
|
47 |
+
public function getFbId()
|
48 |
+
{
|
49 |
+
return Mage::getStoreConfig('opengraph/facebook/appcode', $this->_getStore());
|
50 |
+
}
|
51 |
+
|
52 |
+
public function getTitle()
|
53 |
+
{
|
54 |
+
return Mage::app()->getLayout()->getBlock('head')->getTitle();
|
55 |
+
}
|
56 |
+
|
57 |
+
public function getSiteName()
|
58 |
+
{
|
59 |
+
return Mage::getStoreConfig('system/website/name');
|
60 |
+
}
|
61 |
+
|
62 |
+
public function getDescription()
|
63 |
+
{
|
64 |
+
return htmlspecialchars($this->getLayout()->getBlock('head')->getDescription());
|
65 |
+
}
|
66 |
+
|
67 |
+
public function getContent()
|
68 |
+
{
|
69 |
+
return $this->helper('core/url')->getCurrentUrl();
|
70 |
+
}
|
71 |
+
|
72 |
+
public function getLocale()
|
73 |
+
{
|
74 |
+
return Mage::getStoreConfig('general/locale/code', $this->_getStore());
|
75 |
+
}
|
76 |
+
public function getFbEnable()
|
77 |
+
{
|
78 |
+
return Mage::getStoreConfig('opengraph/facebook/enable', $this->_getStore());
|
79 |
+
}
|
80 |
+
public function getTwitterEnable()
|
81 |
+
{
|
82 |
+
return Mage::getStoreConfig('opengraph/twitter/enable', $this->_getStore());
|
83 |
+
}
|
84 |
+
|
85 |
+
|
86 |
+
|
87 |
+
|
88 |
+
}
|
app/code/community/Jaljale/OpenGraph/Helper/Data.php
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Jaljale_OpenGraph_Helper_Data extends Mage_Core_Helper_Abstract
|
3 |
+
{
|
4 |
+
}
|
5 |
+
|
app/code/community/Jaljale/OpenGraph/controllers/IndexController.php
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Jaljale_OpenGraph_IndexController extends Mage_Core_Controller_Front_Action{
|
3 |
+
public function IndexAction() {
|
4 |
+
|
5 |
+
$this->loadLayout();
|
6 |
+
$this->getLayout()->getBlock("head")->setTitle($this->__("Open Graph Tag"));
|
7 |
+
$breadcrumbs = $this->getLayout()->getBlock("breadcrumbs");
|
8 |
+
$breadcrumbs->addCrumb("home", array(
|
9 |
+
"label" => $this->__("Home Page"),
|
10 |
+
"title" => $this->__("Home Page"),
|
11 |
+
"link" => Mage::getBaseUrl()
|
12 |
+
));
|
13 |
+
|
14 |
+
$breadcrumbs->addCrumb("open graph tag", array(
|
15 |
+
"label" => $this->__("Open Graph Tag"),
|
16 |
+
"title" => $this->__("Open Graph Tag")
|
17 |
+
));
|
18 |
+
|
19 |
+
$this->renderLayout();
|
20 |
+
|
21 |
+
}
|
22 |
+
}
|
app/code/community/Jaljale/OpenGraph/etc/adminhtml.xml
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<acl>
|
4 |
+
<resources>
|
5 |
+
<admin>
|
6 |
+
<children>
|
7 |
+
<system>
|
8 |
+
<children>
|
9 |
+
<config>
|
10 |
+
<children>
|
11 |
+
<opengraph translate="title" module="opengraph">
|
12 |
+
<title>Open Graph Setting Section</title>
|
13 |
+
<sort_order>0</sort_order>
|
14 |
+
</opengraph>
|
15 |
+
</children>
|
16 |
+
</config>
|
17 |
+
</children>
|
18 |
+
</system>
|
19 |
+
</children>
|
20 |
+
</admin>
|
21 |
+
</resources>
|
22 |
+
</acl>
|
23 |
+
</config>
|
app/code/community/Jaljale/OpenGraph/etc/config.xml
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<default>
|
4 |
+
<opengraph>
|
5 |
+
<facebook>
|
6 |
+
<enable>0</enable>
|
7 |
+
<appcode>0</appcode>
|
8 |
+
</facebook>
|
9 |
+
<twitter>
|
10 |
+
<enable>0</enable>
|
11 |
+
</twitter>
|
12 |
+
</opengraph>
|
13 |
+
</default>
|
14 |
+
<modules>
|
15 |
+
<Jaljale_OpenGraph>
|
16 |
+
<version>0.1.0</version>
|
17 |
+
</Jaljale_OpenGraph>
|
18 |
+
</modules>
|
19 |
+
<frontend>
|
20 |
+
<routers>
|
21 |
+
<opengraph>
|
22 |
+
<use>standard</use>
|
23 |
+
<args>
|
24 |
+
<module>Jaljale_OpenGraph</module>
|
25 |
+
<frontName>opengraph</frontName>
|
26 |
+
</args>
|
27 |
+
</opengraph>
|
28 |
+
</routers>
|
29 |
+
<layout>
|
30 |
+
<updates>
|
31 |
+
<opengraph>
|
32 |
+
<file>opengraph.xml</file>
|
33 |
+
</opengraph>
|
34 |
+
</updates>
|
35 |
+
</layout>
|
36 |
+
</frontend>
|
37 |
+
<global>
|
38 |
+
<helpers>
|
39 |
+
<opengraph>
|
40 |
+
<class>Jaljale_OpenGraph_Helper</class>
|
41 |
+
</opengraph>
|
42 |
+
</helpers>
|
43 |
+
<blocks>
|
44 |
+
<opengraph>
|
45 |
+
<class>Jaljale_OpenGraph_Block</class>
|
46 |
+
</opengraph>
|
47 |
+
</blocks>
|
48 |
+
</global>
|
49 |
+
</config>
|
app/code/community/Jaljale/OpenGraph/etc/system.xml
ADDED
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<tabs>
|
4 |
+
<jaljale translate="label" module="opengraph">
|
5 |
+
<label>Jaljale</label>
|
6 |
+
<sort_order>0</sort_order>
|
7 |
+
</jaljale>
|
8 |
+
</tabs>
|
9 |
+
<sections>
|
10 |
+
<opengraph translate="label" module="opengraph">
|
11 |
+
<label>Social Meta Tags</label>
|
12 |
+
<tab>jaljale</tab>
|
13 |
+
<frontend_type>text</frontend_type>
|
14 |
+
<sort_order>0</sort_order>
|
15 |
+
<show_in_default>1</show_in_default>
|
16 |
+
<show_in_website>1</show_in_website>
|
17 |
+
<show_in_store>1</show_in_store>
|
18 |
+
<groups>
|
19 |
+
<twitter translate="label">
|
20 |
+
<label>Twitter Card Tags</label>
|
21 |
+
<frontend_type>text</frontend_type>
|
22 |
+
<sort_order>0</sort_order>
|
23 |
+
<show_in_default>1</show_in_default>
|
24 |
+
<show_in_website>1</show_in_website>
|
25 |
+
<show_in_store>1</show_in_store>
|
26 |
+
<fields>
|
27 |
+
<enable translate="label">
|
28 |
+
<label>Enable</label>
|
29 |
+
<frontend_type>select</frontend_type>
|
30 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
31 |
+
<sort_order>0</sort_order>
|
32 |
+
<show_in_default>1</show_in_default>
|
33 |
+
<show_in_website>1</show_in_website>
|
34 |
+
<show_in_store>1</show_in_store>
|
35 |
+
</enable>
|
36 |
+
</fields>
|
37 |
+
</twitter>
|
38 |
+
<facebook translate="label">
|
39 |
+
<label>Facebook Open Graph</label>
|
40 |
+
<frontend_type>text</frontend_type>
|
41 |
+
<sort_order>0</sort_order>
|
42 |
+
<show_in_default>1</show_in_default>
|
43 |
+
<show_in_website>1</show_in_website>
|
44 |
+
<show_in_store>1</show_in_store>
|
45 |
+
<fields>
|
46 |
+
<appcode translate="label">
|
47 |
+
<label>Facebook App Id</label>
|
48 |
+
<frontend_type>text</frontend_type>
|
49 |
+
<sort_order>0</sort_order>
|
50 |
+
<show_in_default>1</show_in_default>
|
51 |
+
<show_in_website>1</show_in_website>
|
52 |
+
<show_in_store>1</show_in_store>
|
53 |
+
<depends><enable>1</enable></depends>
|
54 |
+
<comment>Create Id from https://developers.facebook.com/apps</comment>
|
55 |
+
</appcode>
|
56 |
+
<enable translate="label">
|
57 |
+
<label>Enable</label>
|
58 |
+
<frontend_type>select</frontend_type>
|
59 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
60 |
+
<sort_order>0</sort_order>
|
61 |
+
<show_in_default>1</show_in_default>
|
62 |
+
<show_in_website>1</show_in_website>
|
63 |
+
<show_in_store>1</show_in_store>
|
64 |
+
</enable>
|
65 |
+
</fields>
|
66 |
+
</facebook>
|
67 |
+
<common translate="label">
|
68 |
+
<label>Default Image</label>
|
69 |
+
<frontend_type>text</frontend_type>
|
70 |
+
<sort_order>0</sort_order>
|
71 |
+
<show_in_default>1</show_in_default>
|
72 |
+
<show_in_website>1</show_in_website>
|
73 |
+
<show_in_store>1</show_in_store>
|
74 |
+
<fields>
|
75 |
+
<image translate="label">
|
76 |
+
<label>Default Image</label>
|
77 |
+
<frontend_type>image</frontend_type>
|
78 |
+
<backend_model>adminhtml/system_config_backend_image</backend_model>
|
79 |
+
<upload_dir config="system/filesystem/media" scope_info="1">jaljale</upload_dir>
|
80 |
+
<base_url type="media" scope_info="1">jaljale</base_url>
|
81 |
+
<sort_order>0</sort_order>
|
82 |
+
<show_in_default>1</show_in_default>
|
83 |
+
<show_in_website>1</show_in_website>
|
84 |
+
<show_in_store>1</show_in_store>
|
85 |
+
<comment>(*.jpg, *.png, *.gif) Applicable for both facebook and twitter</comment>
|
86 |
+
</image>
|
87 |
+
</fields>
|
88 |
+
</common>
|
89 |
+
</groups>
|
90 |
+
</opengraph>
|
91 |
+
</sections>
|
92 |
+
</config>
|
app/design/frontend/base/default/layout/opengraph.xml
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<layout version="0.1.0">
|
3 |
+
<default>
|
4 |
+
<reference name="root">
|
5 |
+
<action method="setTemplate"><template>page/1column.phtml</template></action>
|
6 |
+
</reference>
|
7 |
+
<reference name="head">
|
8 |
+
<block type="opengraph/index" name="opengraph_index" template="opengraph/index.phtml"/>
|
9 |
+
</reference>
|
10 |
+
</default>
|
11 |
+
</layout>
|
12 |
+
|
app/design/frontend/base/default/template/opengraph/index.phtml
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
if($this->getFbEnable()):
|
3 |
+
if($this->getFbId()): ?>
|
4 |
+
<meta property="fb:app_id" content="<?php echo $this->getFbId(); ?>">
|
5 |
+
<meta property="og:title" content="<?php echo $this->getTitle(); ?>">
|
6 |
+
<meta property="og:site_name" content="<?php echo $this->getSiteName(); ?>">
|
7 |
+
<meta property="og:description" content="<?php echo $this->getDescription(); ?>">
|
8 |
+
<meta property="og:url" content="<?php echo $this->getContent(); ?>">
|
9 |
+
<meta property="og:type" content="<?php echo $this->getType(); ?>">
|
10 |
+
<meta property="og:locale" content="<?php echo $this->getLocale(); ?>">
|
11 |
+
<meta property="og:image" content="<?php echo $this->getImage(); ?>">
|
12 |
+
<?php
|
13 |
+
endif;
|
14 |
+
endif;
|
15 |
+
|
16 |
+
if($this->getTwitterEnable()): ?>
|
17 |
+
<meta name="twitter:card" content="summary_large_image">
|
18 |
+
<meta name="twitter:widgets:csp" content="on">
|
19 |
+
<meta name="twitter:url" content="<?php echo $this->getContent(); ?>">
|
20 |
+
<meta name="twitter:description" content="<?php echo $this->getDescription(); ?>">
|
21 |
+
<meta name="twitter:title" content="<?php echo $this->getTitle(); ?>">
|
22 |
+
<meta name="twitter:site" content="<?php echo $this->getSiteName(); ?>">
|
23 |
+
<meta name="twitter:image" content="<?php echo $this->getImage(); ?>">
|
24 |
+
|
25 |
+
<?php endif; ?>
|
app/etc/modules/Jaljale_OpenGraph.xml
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" ?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Jaljale_OpenGraph>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>community</codePool>
|
7 |
+
<version>0.1.0</version>
|
8 |
+
</Jaljale_OpenGraph>
|
9 |
+
</modules>
|
10 |
+
</config>
|
package.xml
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>Jaljale_Social_Tags</name>
|
4 |
+
<version>1.0.0</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license uri="http://www.gnu.org/licenses/gpl-3.0.en.html">GNU General Public License (GPL)</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>Social Meta inserts Facebook Open Graph (og tags) and Twitter Cards (twitter tags) automatically in your store. Hence giving you better control how your pages appear in social stream when it is shared. Facebook Open Graph allows any web page to have the same functionality as any other object on Facebook and for Twitter you can use Twitter Card. Use this extension to Make your Magento store Graph compatible and enable any web page on your site to become a rich object in a social graph. 
|
10 |
+
</summary>
|
11 |
+
<description>Social Meta inserts Facebook Open Graph (og tags) and Twitter Cards (twitter tags) automatically in your store. Hence giving you better control how your pages appear in social stream when it is shared. Facebook Open Graph allows any web page to have the same functionality as any other object on Facebook and for Twitter you can use Twitter Card. Use this extension to Make your Magento store Graph compatible and enable any web page on your site to become a rich object in a social graph. 
|
12 |
+
</description>
|
13 |
+
<notes>Initial version for Facebook Open Graph and Twitter Cards</notes>
|
14 |
+
<authors><author><name>Krish</name><user>jaljale</user><email>jaljaletech@gmail.com</email></author><author><name>Subin Shrestha</name><user>sthasbin</user><email>sthasbin@jaljale.com</email></author></authors>
|
15 |
+
<date>2015-06-17</date>
|
16 |
+
<time>05:03:43</time>
|
17 |
+
<contents><target name="magecommunity"><dir name="Jaljale"><dir name="OpenGraph"><dir name="Block"><file name="Index.php" hash="373efd5a6abdd94655f809baab524eb6"/></dir><dir name="Helper"><file name="Data.php" hash="0523e2a4b93602d4975f8c2adae0127a"/></dir><dir name="controllers"><file name="IndexController.php" hash="970ebec884c711e8b62d36646db615a7"/></dir><dir name="etc"><file name="adminhtml.xml" hash="6761aa4de7c9edc4dbfda4cb9bce7b31"/><file name="config.xml" hash="76f2468c41e89a8d7038464ad24722a5"/><file name="system.xml" hash="7471567f8985aae8a3c76a012cffb1eb"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="opengraph.xml" hash="1b6501b1826228932a973609f521bdd2"/></dir><dir name="template"><dir name="opengraph"><file name="index.phtml" hash="8f04b3e1d2c2886f53828a3409ddfe15"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Jaljale_OpenGraph.xml" hash="20851daa8f866252a6ec02578d33e432"/></dir></target></contents>
|
18 |
+
<compatible/>
|
19 |
+
<dependencies><required><php><min>5.1.3</min><max>6.5.5</max></php></required></dependencies>
|
20 |
+
</package>
|