Kvh_Simpleseo - Version 0.2.0

Version Notes

Add Field for Meta TItle for CMS Page

Download this release

Release Info

Developer Hitesh Agrawal
Extension Kvh_Simpleseo
Version 0.2.0
Comparing to
See all releases


Code changes from version 0.1.0 to 0.2.0

app/code/local/Kvh/SimpleSeo/etc/config.xml DELETED
@@ -1,24 +0,0 @@
1
- <?xml version="1.0"?>
2
- <config>
3
- <modules>
4
- <Kvh_Simpleseo>
5
- <version>0.1.0</version>
6
- </Kvh_Simpleseo>
7
- </modules>
8
-
9
- <global>
10
-
11
-
12
- <blocks>
13
- <simpleseo>
14
- <class>Kvh_Simpleseo_Block</class>
15
- </simpleseo>
16
- <catalog>
17
- <rewrite>
18
- <product_view>Kvh_Simpleseo_Block_Catalog_Product_View</product_view>
19
- <category_view>Kvh_Simpleseo_Block_Catalog_Category_View</category_view>
20
- </rewrite>
21
- </catalog>
22
- </blocks>
23
- </global>
24
- </config>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Kvh/{SimpleSeo → Simpleseo}/Block/Catalog/Category/View.php RENAMED
File without changes
app/code/local/Kvh/{SimpleSeo → Simpleseo}/Block/Catalog/Product/View.php RENAMED
@@ -31,15 +31,19 @@ class Kvh_Simpleseo_Block_Catalog_Product_View extends Mage_Catalog_Block_Produc
31
 
32
 
33
  $product = $this->getProduct();
 
 
34
 
35
  $word=array_unique($words[1]);
36
 
37
-
38
  foreach($word as $w)
39
  {
40
- $p= strpos($w,'product_');
41
-
42
- if($p==0)
 
 
43
  {
44
  $attribute=substr($w,8);
45
  $attributeModel = Mage::getModel('eav/entity_attribute')->loadByCode("catalog_product",$attribute);
@@ -57,9 +61,37 @@ class Kvh_Simpleseo_Block_Catalog_Product_View extends Mage_Catalog_Block_Produc
57
 
58
  }
59
  $product_meta_title=str_replace("[".$w."]",$data,$product_meta_title);
60
- $product_meta_keyword=str_replace("[".$w."]",$data,$product_meta_keyword);
61
- $product_meta_description=str_replace("[".$w."]",$data,$product_meta_description);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
62
  }
 
 
 
 
63
 
64
  }
65
  $headBlock = $this->getLayout()->getBlock('head');
31
 
32
 
33
  $product = $this->getProduct();
34
+ $currentCategory = Mage::registry('current_category');
35
+
36
 
37
  $word=array_unique($words[1]);
38
 
39
+
40
  foreach($word as $w)
41
  {
42
+ $data="";
43
+ $cdata="";
44
+ $p= explode("_",$w);
45
+
46
+ if($p[0]=="product")
47
  {
48
  $attribute=substr($w,8);
49
  $attributeModel = Mage::getModel('eav/entity_attribute')->loadByCode("catalog_product",$attribute);
61
 
62
  }
63
  $product_meta_title=str_replace("[".$w."]",$data,$product_meta_title);
64
+ $product_meta_keyword=str_replace("[".$w."]",$data,$product_meta_keyword);
65
+ $product_meta_description=str_replace("[".$w."]",$data,$product_meta_description);
66
+
67
+ }
68
+
69
+ if($p[0]=="category")
70
+ {
71
+ $attribute=substr($w,9);
72
+ $attributeModel = Mage::getModel('eav/entity_attribute')->loadByCode("catalog_category",$attribute);
73
+
74
+ $attrtype=$attributeModel->getFrontendInput();
75
+
76
+ switch($attrtype)
77
+ {
78
+ case "text":
79
+ $cdata=$currentCategory->getData($attribute);
80
+ break;
81
+ case "select":
82
+ $cdata=$currentCategory->getAttributeText($attribute);
83
+ break;
84
+
85
+ }
86
+ $product_meta_title=str_replace("[".$w."]",$cdata,$product_meta_title);
87
+ $product_meta_keyword=str_replace("[".$w."]",$cdata,$product_meta_keyword);
88
+ $product_meta_description=str_replace("[".$w."]",$cdata,$product_meta_description);
89
+
90
  }
91
+
92
+
93
+
94
+
95
 
96
  }
97
  $headBlock = $this->getLayout()->getBlock('head');
app/code/local/Kvh/Simpleseo/Block/Cms/Page.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Catalog
23
+ * @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Category View block
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Catalog
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Kvh_Simpleseo_Block_Cms_Page extends Mage_Cms_Block_Page
35
+ {
36
+ /**
37
+ * Add meta information from product to head block
38
+ *
39
+ * @return Mage_Catalog_Block_Product_View
40
+ */
41
+ protected function _prepareLayout()
42
+ {
43
+ parent::_prepareLayout();
44
+
45
+ $page = $this->getPage();
46
+
47
+ $head = $this->getLayout()->getBlock('head');
48
+ $meta_title = $page->getMetaTitle();
49
+
50
+ if ($head && $meta_title) {
51
+ $head->setTitle($meta_title);
52
+
53
+ }
54
+
55
+
56
+
57
+
58
+
59
+ }
60
+
61
+ }
app/code/local/Kvh/Simpleseo/Model/Mysql4/Simpleseo.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Kvh_Simpleseo_Model_Mysql4_Simpleseo extends Mage_Core_Model_Mysql4_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+
8
+ }
9
+ }
app/code/local/Kvh/Simpleseo/Model/Mysql4/Simpleseo/Collection.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Kvh_Simpleseo_Model_Mysql4_Simpleseo_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('simpleseo/simpleseo');
9
+ }
10
+ }
app/code/local/Kvh/Simpleseo/Model/Observer.php ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Simpleseo
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Checkout observer model
29
+ *
30
+ * @category Mage
31
+ * @package Mage_SimpleSeo
32
+ * @author Magento Community Team (kvhsolutions@gmail.com)
33
+ */
34
+ class Kvh_Simpleseo_Model_Observer
35
+ {
36
+ public function addMetaTitle(Varien_Event_Observer $observer)
37
+ {
38
+ $model = Mage::registry('cms_page');
39
+ $form = $observer->getEvent()->getForm();
40
+ //get CMS model with data
41
+
42
+ //get form instance
43
+ //$form = $observer->getForm();
44
+ //create new custom fieldset 'atwix_content_fieldset'
45
+ //$fieldset = $form->addFieldset('kvh_content_fieldset', array('legend'=>Mage::helper('cms')->__('Meta Data'),'class'=>'fieldset-wide'));
46
+ //add new field
47
+ // $fieldset = $form->addFieldset('meta_fieldset', array('legend' => Mage::helper('cms')->__('Meta Data'), 'class' => 'fieldset-wide'));
48
+ // $form = $observer->getEvent()->getForm();
49
+ // $fieldset = $form->getFieldset('meta_fieldset');
50
+ //$fieldset = $form->getFieldset('meta_fieldset');
51
+ $fieldset = $form->getElement('meta_fieldset');
52
+
53
+
54
+
55
+ $fieldset->addField('meta_title', 'text', array(
56
+ 'name' => 'meta_title',
57
+ 'label' => Mage::helper('cms')->__('Meta Title'),
58
+ 'title' => Mage::helper('cms')->__('Meta Title'),
59
+ 'disabled' => false,
60
+ //set field value
61
+ 'value' => $model->getMetaTitle()
62
+ ));
63
+
64
+ }
65
+
66
+
67
+
68
+
69
+ }
app/code/local/Kvh/Simpleseo/Model/Simpleseo.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Kvh_Simpleseo_Model_Simpleseo extends Mage_Core_Model_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('simpleseo/simpleseo');
9
+ }
10
+
11
+
12
+
13
+
14
+ }
app/code/local/Kvh/Simpleseo/etc/config.xml ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Kvh_Simpleseo>
5
+ <version>0.2.0</version>
6
+ </Kvh_Simpleseo>
7
+ </modules>
8
+
9
+ <global>
10
+ <models>
11
+ <simpleseo>
12
+ <class>Kvh_Simpleseo_Model</class>
13
+ <resourceModel>simpleseo_mysql4</resourceModel>
14
+ </simpleseo>
15
+ <simpleseo_mysql4>
16
+ <class>Kvh_Simpleseo_Model_Mysql4</class>
17
+ <entities>
18
+ <simpleseo>
19
+ <table>simpleseo</table>
20
+ </simpleseo>
21
+ </entities>
22
+ </simpleseo_mysql4>
23
+ </models>
24
+ <resources>
25
+ <simpleseo_setup>
26
+ <setup>
27
+ <module>Kvh_Simpleseo</module>
28
+ </setup>
29
+ <connection>
30
+ <use>core_setup</use>
31
+ </connection>
32
+ </simpleseo_setup>
33
+ <simpleseo_write>
34
+ <connection>
35
+ <use>core_write</use>
36
+ </connection>
37
+ </simpleseo_write>
38
+ <simpleseo_read>
39
+ <connection>
40
+ <use>core_read</use>
41
+ </connection>
42
+ </simpleseo_read>
43
+ </resources>
44
+
45
+ <blocks>
46
+ <simpleseo>
47
+ <class>Kvh_Simpleseo_Block</class>
48
+ </simpleseo>
49
+ <catalog>
50
+ <rewrite>
51
+ <product_view>Kvh_Simpleseo_Block_Catalog_Product_View</product_view>
52
+ <category_view>Kvh_Simpleseo_Block_Catalog_Category_View</category_view>
53
+ </rewrite>
54
+ </catalog>
55
+ <cms>
56
+ <rewrite>
57
+ <page>Kvh_Simpleseo_Block_Cms_Page</page>
58
+
59
+ </rewrite>
60
+ </cms>
61
+
62
+ </blocks>
63
+
64
+ <events>
65
+ <adminhtml_cms_page_edit_tab_meta_prepare_form>
66
+ <observers>
67
+ <kvh_simpleseo_page_edit_tab_content>
68
+ <type>singleton</type>
69
+ <class>Kvh_Simpleseo_Model_Observer</class>
70
+ <method>addMetaTitle</method>
71
+ </kvh_simpleseo_page_edit_tab_content>
72
+ </observers>
73
+ </adminhtml_cms_page_edit_tab_meta_prepare_form>
74
+
75
+
76
+
77
+
78
+ </events>
79
+
80
+
81
+ </global>
82
+ </config>
app/code/local/Kvh/{SimpleSeo → Simpleseo}/etc/system.xml RENAMED
File without changes
app/code/local/Kvh/Simpleseo/sql/simpleseo_setup/mysql4-install-0.2.0.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+
5
+ $installer->startSetup();
6
+
7
+
8
+ $installer->run("
9
+
10
+ ALTER TABLE {$this->getTable('cms_page')}
11
+ ADD COLUMN `meta_title` varchar(255) NULL
12
+
13
+ ");
14
+
15
+
16
+ $installer->endSetup();
package.xml CHANGED
@@ -1,44 +1,18 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Kvh_Simpleseo</name>
4
- <version>0.1.0</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">OSL</license>
7
  <channel>community</channel>
8
  <extends/>
9
- <summary>Simple Seo for Set Meta data on Fly</summary>
10
- <description>SimpleSeo extension is use for set Dynamic Meta Data on Fly with a simple configuration&#xD;
11
- &#xD;
12
- You can set Meta Title , Meta Keyword and Meta Description dynamic&#xD;
13
- &#xD;
14
- Example if your product name is XYZ Product&#xD;
15
- and you want to set meta title like Buy XYZ Product from ABC Brand then you can set it by set configuration like&#xD;
16
- Buy [product_name] from [product_manufacturer] Brand&#xD;
17
- &#xD;
18
- Instruction&#xD;
19
- &#xD;
20
- 1) Go to System &gt; Configuration &#xD;
21
- 2) Select Catalog from left bar&#xD;
22
- 3) Select Simple Seo Section&#xD;
23
- 4) If you want to set the meta data formula then and want to use category attributes like name then you have to use like this&#xD;
24
- [category_name] Where category_ is the prefix and name is the category attribute, you have to use prefix category_ for category attributes and prefix product_ for product attribute, please check screenshot for more information&#xD;
25
- &#xD;
26
- if you need any assistance for installation and configuration then contact us at kvhsolutions@gmail.com&#xD;
27
- &#xD;
28
- &#xD;
29
- &#xD;
30
- &#xD;
31
- &#xD;
32
- &#xD;
33
- &#xD;
34
- &#xD;
35
- &#xD;
36
- </description>
37
- <notes>Introducing the first version of simple seo</notes>
38
  <authors><author><name>Hitesh Agrawal</name><user>hiteshmca111</user><email>hiteshagrawal84@gmail.com</email></author></authors>
39
- <date>2014-04-19</date>
40
- <time>10:00:34</time>
41
- <contents><target name="magelocal"><dir name="Kvh"><dir name="SimpleSeo"><dir name="Block"><dir name="Catalog"><dir name="Category"><file name="View.php" hash="323bfab0a57537cf31bb194249d742b0"/></dir><dir name="Product"><file name="View.php" hash="e779f1ea6d2ebb5cb088f33874abe2ac"/></dir></dir></dir><dir name="etc"><file name="config.xml" hash="5fadf3f0393b37b97081a4523d33a9fd"/><file name="system.xml" hash="d211de5b39a2be97d9c9b34807df4de9"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Kvh_Simpleseo.xml" hash="6cb871dc56b9e5b4e0b13ef121723011"/></dir></target></contents>
42
  <compatible/>
43
  <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
44
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Kvh_Simpleseo</name>
4
+ <version>0.2.0</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">OSL</license>
7
  <channel>community</channel>
8
  <extends/>
9
+ <summary>Set Meta Deta for Category Product and CMS Page</summary>
10
+ <description>Set Meta Deta for Category Product and CMS Page</description>
11
+ <notes>Add Field for Meta TItle for CMS Page</notes>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  <authors><author><name>Hitesh Agrawal</name><user>hiteshmca111</user><email>hiteshagrawal84@gmail.com</email></author></authors>
13
+ <date>2014-05-03</date>
14
+ <time>07:03:47</time>
15
+ <contents><target name="magelocal"><dir name="Kvh"><dir name="Simpleseo"><dir name="Block"><dir name="Catalog"><dir name="Category"><file name="View.php" hash="323bfab0a57537cf31bb194249d742b0"/></dir><dir name="Product"><file name="View.php" hash="ed453215d56eb69d2d711ec90a00e714"/></dir></dir><dir name="Cms"><file name="Page.php" hash="fe3a5de0e4f077971f7b4f89b295e943"/></dir></dir><dir name="Model"><dir name="Mysql4"><dir name="Simpleseo"><file name="Collection.php" hash="5fbd40e6e9a88afd782347a366900844"/></dir><file name="Simpleseo.php" hash="f605ec62d70f16c372f22e64654c0ab6"/></dir><file name="Observer.php" hash="12cf363b801d3f040a6e72cc8d4eecbf"/><file name="Simpleseo.php" hash="cdd9f7ced30b06f8b82a83038bd3c883"/></dir><dir name="etc"><file name="config.xml" hash="fb31c1b447668ddff25d8e8c8f3fe1cc"/><file name="system.xml" hash="d211de5b39a2be97d9c9b34807df4de9"/></dir><dir name="sql"><dir name="simpleseo_setup"><file name="mysql4-install-0.2.0.php" hash="e6c4d3f985200a5f38b5f3465311d9cc"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Kvh_Simpleseo.xml" hash="6cb871dc56b9e5b4e0b13ef121723011"/></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
18
  </package>