DwD_CmsMenu - Version 0.1.0

Version Notes

First release.

Download this release

Release Info

Developer Damian A. Pastorini
Extension DwD_CmsMenu
Version 0.1.0
Comparing to
See all releases


Version 0.1.0

app/code/community/DwD/CmsMenu/Block/Adminhtml/Cms/Page/Edit/Tab/Content.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * DwD-CmsMenu - Magento Extension
6
+ *
7
+ * @copyright Copyright (c) 2015 DwDesigner Inc. (http://www.dwdeveloper.com/)
8
+ * @author Damian A. Pastorini - damian.pastorini@dwdeveloper.com
9
+ *
10
+ */
11
+
12
+ class DwD_CmsMenu_Block_Adminhtml_Cms_Page_Edit_Tab_Content extends Mage_Adminhtml_Block_Widget_Form
13
+ {
14
+
15
+ public function prepareForm($observer)
16
+ {
17
+ $isEnabled = Mage::getStoreConfig('dwd_cmsmenu/general/enabled');
18
+ if($isEnabled) {
19
+ $form = $observer->getForm();
20
+ $menuFieldset = $form->addFieldset('menu_fieldset', array('legend' => Mage::helper('cms')->__('Top Menu')));
21
+ $yesnoSource = Mage::getModel('adminhtml/system_config_source_yesno')->toArray();
22
+ $menuFieldset->addField('show_in_menu', 'select', array(
23
+ 'label' => Mage::helper('cms')->__('Show in Menu'),
24
+ 'title' => Mage::helper('cms')->__('Show in Menu'),
25
+ 'name' => 'show_in_menu',
26
+ 'options' => $yesnoSource,
27
+ ));
28
+ $menuFieldset->addField('menu_item_title', 'text', array(
29
+ 'label' => Mage::helper('cms')->__('Menu Title'),
30
+ 'name' => 'menu_item_title',
31
+ 'note' => Mage::helper('cms')->__('If empty the item name will be the page title.'),
32
+ ));
33
+ $fathersList = Mage::helper('dwd_cmsmenu')->getFathersList();
34
+ $menuFieldset->addField('child_of', 'select', array(
35
+ 'label' => Mage::helper('cms')->__('Show as child of'),
36
+ 'title' => Mage::helper('cms')->__('Show as child of'),
37
+ 'name' => 'child_of',
38
+ 'values' => $fathersList,
39
+ 'note' => Mage::helper('cms')->__('If empty the item will be displayed in the top level.'),
40
+ ));
41
+ $menuFieldset->addField('add_before', 'select', array(
42
+ 'label' => Mage::helper('cms')->__('Add before'),
43
+ 'title' => Mage::helper('cms')->__('Add before'),
44
+ 'name' => 'add_before',
45
+ 'values' => $fathersList,
46
+ 'note' => Mage::helper('cms')->__('If empty the item will be added as last. If you have multiple items without this value those will be added at the end ordered by the identifier.'),
47
+ ));
48
+ }
49
+ }
50
+
51
+ }
app/code/community/DwD/CmsMenu/Block/Page/Html/Topmenu/Observer.php ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * DwD-CmsMenu - Magento Extension
6
+ *
7
+ * @copyright Copyright (c) 2015 DwDesigner Inc. (http://www.dwdeveloper.com/)
8
+ * @author Damian A. Pastorini - damian.pastorini@dwdeveloper.com
9
+ *
10
+ */
11
+
12
+ class DwD_CmsMenu_Block_Page_Html_Topmenu_Observer extends Mage_Page_Block_Html_Topmenu
13
+ {
14
+
15
+ public function addMenuItems($observer)
16
+ {
17
+ $isEnabled = Mage::getStoreConfig('dwd_cmsmenu/general/enabled');
18
+ if($isEnabled) {
19
+ // get all items that should be added at the end of the tree:
20
+ $cmsMenuItems = Mage::getModel('dwd_cmsmenu/cmsmenu')->getCollection()->addActiveFilter()->setChildOfOrder()->setAddBeforeOrder();
21
+ // loop items and add to the menu:
22
+ foreach ($cmsMenuItems as $menuItem) {
23
+ // get item name:
24
+ $itemName = $this->getItemName($menuItem);
25
+ // get item url:
26
+ $itemUrl = Mage::helper('cms/page')->getPageUrl($menuItem->getCmsPageId());
27
+ // check if the item is active:
28
+ $is_active = $this->getItemStatus($itemUrl);
29
+ // create the item data array:
30
+ $itemNodeData = array(
31
+ 'name' => $itemName,
32
+ 'id' => 'cmsmenu-'.$menuItem->getCmsPageId(),
33
+ 'cmsmenu-'.$menuItem->getCmsPageId() => 'cmsmenu-'.$menuItem->getCmsPageId(),
34
+ 'url' => $itemUrl,
35
+ 'is_active' => $is_active,
36
+ 'level' => 0,
37
+ 'is_first' => false, // TODO: fix.
38
+ 'is_last' => false, // TODO: fix.
39
+ 'class' => 'cmsmenu-'.$menuItem->getCmsPageId()
40
+ );
41
+ // child of items:
42
+ if($menuItem->getChildOf()) {
43
+ // get all child nodes:
44
+ $allChildNodes = $observer->getMenu()->getAllChildNodes();
45
+ // look for the parent item:
46
+ $parentItem = $allChildNodes[$menuItem->getChildOf()];
47
+ if($parentItem) {
48
+ // create new item node:
49
+ $itemNode = new Varien_Data_Tree_Node($itemNodeData, 'cmsmenu-'.$menuItem->getCmsPageId(), $parentItem->getTree());
50
+ if(!$menuItem->getAddBefore()) {
51
+ // add item at the end:
52
+ $parentItem->addChild($itemNode);
53
+ } else {
54
+ // add before case, get parent item childs:
55
+ $currentChilds = $parentItem->getChildren();
56
+ if($currentChilds) {
57
+ // loop and reorder items:
58
+ foreach($currentChilds as $childIndex => $currentChild) {
59
+ $parentItem->removeChild($currentChild);
60
+ if($childIndex == $menuItem->getAddBefore()) {
61
+ $parentItem->addChild($itemNode);
62
+ }
63
+ $parentItem->addChild($currentChild);
64
+ }
65
+ } else {
66
+ // if there are no childs add the item normally:
67
+ $parentItem->addChild($itemNode);
68
+ }
69
+ }
70
+ }
71
+ } else {
72
+ // create new node:
73
+ $itemNode = new Varien_Data_Tree_Node($itemNodeData, 'cmsmenu-' . $menuItem->getCmsPageId(), $observer->getMenu()->getTree());
74
+ // top level items:
75
+ if(!$menuItem->getAddBefore()) {
76
+ // add item at the end:
77
+ $observer->getMenu()->addChild($itemNode);
78
+ } else {
79
+ // get menu items:
80
+ $currentChilds = $observer->getMenu()->getChildren();
81
+ if($currentChilds) {
82
+ // loop and reorder items:
83
+ foreach($currentChilds as $childIndex => $currentChild) {
84
+ $observer->getMenu()->removeChild($currentChild);
85
+ if($childIndex == $menuItem->getAddBefore()) {
86
+ $observer->getMenu()->addChild($itemNode);
87
+ }
88
+ $observer->getMenu()->addChild($currentChild);
89
+ }
90
+ } else {
91
+ // if there are no items just add the child normally:
92
+ $observer->getMenu()->addChild($itemNode);
93
+ }
94
+ }
95
+ }
96
+ }
97
+ }
98
+ return $observer;
99
+ }
100
+
101
+ public function getItemName($menuItem)
102
+ {
103
+ $itemName = $menuItem->getMenuItemTitle();
104
+ if(!$itemName) {
105
+ // if the item title is not specified then get the title from the page:
106
+ $cmsPage = Mage::getModel('cms/page')->load($menuItem->getCmsPageId());
107
+ $itemName = $cmsPage->getTitle();
108
+ }
109
+ return $itemName;
110
+ }
111
+
112
+ public function getItemStatus($itemUrl)
113
+ {
114
+ $isActive = false;
115
+ // get current url:
116
+ $currentUrl = rtrim(Mage::helper('core/url')->getCurrentUrl(), '/');
117
+ // get item url:
118
+ $currentPageUrl = rtrim($itemUrl, '/');
119
+ // validate:
120
+ if ($currentPageUrl == $currentUrl) {
121
+ $isActive = true;
122
+ }
123
+ return $isActive;
124
+ }
125
+
126
+ }
app/code/community/DwD/CmsMenu/Helper/Data.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * DwD-CmsMenu - Magento Extension
6
+ *
7
+ * @copyright Copyright (c) 2015 DwDesigner Inc. (http://www.dwdeveloper.com/)
8
+ * @author Damian A. Pastorini - damian.pastorini@dwdeveloper.com
9
+ *
10
+ */
11
+
12
+ class DwD_CmsMenu_Helper_Data extends Mage_Core_Helper_Abstract
13
+ {
14
+
15
+ public function getFathersList()
16
+ {
17
+ $options = array(
18
+ '0' => '',
19
+ '1' => array(
20
+ 'label'=> 'Pages',
21
+ 'value' => array()
22
+ ),
23
+ '2' => array(
24
+ 'label'=> 'Categories',
25
+ 'value' => array()
26
+ ),
27
+ );
28
+ $pages = Mage::getModel('cms/page')->getCollection();
29
+ foreach ($pages as $p) {
30
+ $options['1']['value'][] = array ('value'=>'cmsmenu-'.$p->getId(), 'label' => $p->getTitle());
31
+ }
32
+ // TODO: add categories filters for status and level.
33
+ $categories = Mage::getModel('catalog/category')->getCollection()->addAttributeToSelect(array('name'));
34
+ foreach ($categories as $c) {
35
+ $options['2']['value'][] = array('value'=>'category-node-'.$c->getId(), 'label' => $c->getName());
36
+ }
37
+ return $options;
38
+ }
39
+
40
+ }
app/code/community/DwD/CmsMenu/Model/Cmsmenu.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * DwD-CmsMenu - Magento Extension
6
+ *
7
+ * @copyright Copyright (c) 2015 DwDesigner Inc. (http://www.dwdeveloper.com/)
8
+ * @author Damian A. Pastorini - damian.pastorini@dwdeveloper.com
9
+ *
10
+ */
11
+
12
+ class DwD_CmsMenu_Model_Cmsmenu extends Mage_Core_Model_Abstract
13
+ {
14
+
15
+ protected function _construct()
16
+ {
17
+ $this->_init('dwd_cmsmenu/cmsmenu');
18
+ }
19
+
20
+ }
app/code/community/DwD/CmsMenu/Model/Mysql4/Cmsmenu.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * DwD-CmsMenu - Magento Extension
6
+ *
7
+ * @copyright Copyright (c) 2015 DwDesigner Inc. (http://www.dwdeveloper.com/)
8
+ * @author Damian A. Pastorini - damian.pastorini@dwdeveloper.com
9
+ *
10
+ */
11
+
12
+ class DwD_CmsMenu_Model_Mysql4_Cmsmenu extends Mage_Core_Model_Mysql4_Abstract
13
+ {
14
+
15
+ protected function _construct()
16
+ {
17
+ $this->_init('dwd_cmsmenu/cmsmenu', 'id');
18
+ }
19
+
20
+ }
app/code/community/DwD/CmsMenu/Model/Mysql4/Cmsmenu/Collection.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * DwD-CmsMenu - Magento Extension
6
+ *
7
+ * @copyright Copyright (c) 2015 DwDesigner Inc. (http://www.dwdeveloper.com/)
8
+ * @author Damian A. Pastorini - damian.pastorini@dwdeveloper.com
9
+ *
10
+ */
11
+
12
+ class DwD_CmsMenu_Model_Mysql4_Cmsmenu_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
13
+ {
14
+
15
+ public function _construct()
16
+ {
17
+ $this->_init('dwd_cmsmenu/cmsmenu');
18
+ }
19
+
20
+ public function addActiveFilter()
21
+ {
22
+ $this->addFieldToFilter('show_in_menu', array('attribute' => 'show_in_menu', 'eq' => 1));
23
+ return $this;
24
+ }
25
+
26
+ public function addChildOfFilter($childOf=false)
27
+ {
28
+ if(!$childOf) {
29
+ $this->addFieldToFilter('child_of', array('attribute' => 'child_of', array('eq'=>'0', 'n8ull'=>true)));
30
+ } else {
31
+ $this->addFieldToFilter('child_of', array('attribute' => 'child_of', 'eq' => $childOf));
32
+ }
33
+ return $this;
34
+ }
35
+
36
+ public function addBeforeFilter()
37
+ {
38
+ $this->addFieldToFilter('add_before', array('attribute' => 'add_before', 'notnull' => true));
39
+ return $this;
40
+ }
41
+
42
+ public function setChildOfOrder()
43
+ {
44
+ $this->getSelect()->order('child_of', self::SORT_ORDER_ASC);
45
+ return $this;
46
+ }
47
+
48
+ public function setAddBeforeOrder()
49
+ {
50
+ $this->getSelect()->order('add_before', self::SORT_ORDER_ASC);
51
+ return $this;
52
+ }
53
+
54
+ }
app/code/community/DwD/CmsMenu/Model/Observer.php ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * DwD-CmsMenu - Magento Extension
6
+ *
7
+ * @copyright Copyright (c) 2015 DwDesigner Inc. (http://www.dwdeveloper.com/)
8
+ * @author Damian A. Pastorini - damian.pastorini@dwdeveloper.com
9
+ *
10
+ */
11
+
12
+ class DwD_CmsMenu_Model_Observer
13
+ {
14
+
15
+ public function saveCmsMenu($observer)
16
+ {
17
+ $isEnabled = Mage::getStoreConfig('dwd_cmsmenu/general/enabled');
18
+ if($isEnabled) {
19
+ $request = Mage::app()->getRequest();
20
+ $post = $request->getPost();
21
+ $page = $observer->getObject();
22
+ $pageId = $page->getId();
23
+ $cmsMenu = Mage::getModel('dwd_cmsmenu/cmsmenu')->load($pageId, 'cms_page_id');
24
+ if (!$cmsMenu || ($cmsMenu && !$cmsMenu->getId())) {
25
+ $cmsMenu = Mage::getModel('dwd_cmsmenu/cmsmenu');
26
+ }
27
+ $cmsMenu->setCmsPageId($pageId);
28
+ $cmsMenu->setShowInMenu($post['show_in_menu']);
29
+ $cmsMenu->setChildOf($post['child_of']);
30
+ $cmsMenu->setAddBefore($post['add_before']);
31
+ $itemTitle = $post['menu_item_title'];
32
+ if (!$itemTitle) {
33
+ $itemTitle = $post['title'];
34
+ }
35
+ $cmsMenu->setMenuItemTitle($itemTitle);
36
+ $cmsMenu->save();
37
+ }
38
+ }
39
+
40
+ public function addCmsPageData($observer)
41
+ {
42
+ $isEnabled = Mage::getStoreConfig('dwd_cmsmenu/general/enabled');
43
+ if($isEnabled) {
44
+ $page = $observer->getObject();
45
+ $pageId = $page->getId();
46
+ $cmsMenu = Mage::getModel('dwd_cmsmenu/cmsmenu')->load($pageId, 'cms_page_id');
47
+ $page->setData('show_in_menu', $cmsMenu->getShowInMenu());
48
+ $page->setData('child_of', $cmsMenu->getChildOf());
49
+ $page->setData('add_before', $cmsMenu->getAddBefore());
50
+ $page->setData('menu_item_title', $cmsMenu->getMenuItemTitle());
51
+ return $page;
52
+ }
53
+ }
54
+
55
+ }
app/code/community/DwD/CmsMenu/etc/adminhtml.xml ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ *
5
+ * DwD-CmsMenu - Magento Extension
6
+ *
7
+ * @copyright Copyright (c) 2015 DwDesigner Inc. (http://www.dwdeveloper.com/)
8
+ * @author Damian A. Pastorini - damian.pastorini@dwdeveloper.com
9
+ *
10
+ */
11
+ -->
12
+ <config>
13
+ <acl>
14
+ <resources>
15
+ <admin>
16
+ <children>
17
+ <system>
18
+ <children>
19
+ <config>
20
+ <children>
21
+ <dwd_cmsmenu translate="title" module="dwd_cmsmenu">
22
+ <title>DwD Extensions - CMS Menu</title>
23
+ <sort_order>50</sort_order>
24
+ </dwd_cmsmenu>
25
+ </children>
26
+ </config>
27
+ </children>
28
+ </system>
29
+ </children>
30
+ </admin>
31
+ </resources>
32
+ </acl>
33
+ </config>
app/code/community/DwD/CmsMenu/etc/config.xml ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ *
5
+ * DwD-CmsMenu - Magento Extension
6
+ *
7
+ * @copyright Copyright (c) 2015 DwDesigner Inc. (http://www.dwdeveloper.com/)
8
+ * @author Damian A. Pastorini - damian.pastorini@dwdeveloper.com
9
+ *
10
+ */
11
+ -->
12
+ <config>
13
+ <modules>
14
+ <DwD_CmsMenu>
15
+ <version>0.1.0</version>
16
+ </DwD_CmsMenu>
17
+ </modules>
18
+ <global>
19
+ <models>
20
+ <dwd_cmsmenu>
21
+ <class>DwD_CmsMenu_Model</class>
22
+ <resourceModel>dwd_cmsmenu_mysql4</resourceModel>
23
+ </dwd_cmsmenu>
24
+ <dwd_cmsmenu_mysql4>
25
+ <class>DwD_CmsMenu_Model_Mysql4</class>
26
+ <entities>
27
+ <cmsmenu>
28
+ <table>cmsmenu</table>
29
+ </cmsmenu>
30
+ </entities>
31
+ </dwd_cmsmenu_mysql4>
32
+ <dwd_cmsmenu_resource>
33
+ <class>DwD_CmsMenu_Model_Resource</class>
34
+ </dwd_cmsmenu_resource>
35
+ </models>
36
+ <blocks>
37
+ <dwd_cmsmenu>
38
+ <class>DwD_CmsMenu_Block</class>
39
+ </dwd_cmsmenu>
40
+ </blocks>
41
+ <helpers>
42
+ <dwd_cmsmenu>
43
+ <class>DwD_Cmsmenu_Helper</class>
44
+ </dwd_cmsmenu>
45
+ </helpers>
46
+ <events>
47
+ <cms_page_load_after>
48
+ <observers>
49
+ <dwd_cmsmenu_add_page_data>
50
+ <class>DwD_CmsMenu_Model_Observer</class>
51
+ <method>addCmsPageData</method>
52
+ </dwd_cmsmenu_add_page_data>
53
+ </observers>
54
+ </cms_page_load_after>
55
+ </events>
56
+ </global>
57
+ <default>
58
+ <dwd_cmsmenu>
59
+ <general>
60
+ <enabled>1</enabled>
61
+ </general>
62
+ </dwd_cmsmenu>
63
+ </default>
64
+ <frontend>
65
+ <events>
66
+ <page_block_html_topmenu_gethtml_before>
67
+ <observers>
68
+ <dwd_cmsmenu_front>
69
+ <class>DwD_Cmsmenu_Block_Page_Html_Topmenu_Observer</class>
70
+ <method>addMenuItems</method>
71
+ </dwd_cmsmenu_front>
72
+ </observers>
73
+ </page_block_html_topmenu_gethtml_before>
74
+ </events>
75
+ </frontend>
76
+ <adminhtml>
77
+ <events>
78
+ <adminhtml_cms_page_edit_tab_main_prepare_form>
79
+ <observers>
80
+ <flexishore_cms_prepare_form>
81
+ <type>singleton</type>
82
+ <class>DwD_Cmsmenu_Block_Adminhtml_Cms_Page_Edit_Tab_Content</class>
83
+ <method>prepareForm</method>
84
+ </flexishore_cms_prepare_form>
85
+ </observers>
86
+ </adminhtml_cms_page_edit_tab_main_prepare_form>
87
+ <cms_page_save_after>
88
+ <observers>
89
+ <dwd_cmsmenu_save_cmsmenu>
90
+ <class>DwD_CmsMenu_Model_Observer</class>
91
+ <method>saveCmsMenu</method>
92
+ </dwd_cmsmenu_save_cmsmenu>
93
+ </observers>
94
+ </cms_page_save_after>
95
+ </events>
96
+ </adminhtml>
97
+ </config>
app/code/community/DwD/CmsMenu/etc/system.xml ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ *
5
+ * DwD-CmsMenu - Magento Extension
6
+ *
7
+ * @copyright Copyright (c) 2015 DwDesigner Inc. (http://www.dwdeveloper.com/)
8
+ * @author Damian A. Pastorini - damian.pastorini@dwdeveloper.com
9
+ *
10
+ */
11
+ -->
12
+ <config>
13
+ <tabs>
14
+ <dwd_all translate="label">
15
+ <label>DwD Extensions</label>
16
+ <sort_order>100</sort_order>
17
+ </dwd_all>
18
+ </tabs>
19
+ <sections>
20
+ <dwd_cmsmenu translate="label" module="dwd_cmsmenu">
21
+ <label>CMS Menu</label>
22
+ <tab>dwd_all</tab>
23
+ <frontend_type>text</frontend_type>
24
+ <sort_order>120</sort_order>
25
+ <show_in_default>1</show_in_default>
26
+ <show_in_website>1</show_in_website>
27
+ <show_in_store>1</show_in_store>
28
+ <groups>
29
+ <general translate="label">
30
+ <label>General</label>
31
+ <sort_order>800</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
+ <fields>
36
+ <enabled translate="label">
37
+ <label>Enabled</label>
38
+ <frontend_type>select</frontend_type>
39
+ <source_model>adminhtml/system_config_source_yesno</source_model>
40
+ <sort_order>1</sort_order>
41
+ <show_in_default>1</show_in_default>
42
+ <show_in_website>1</show_in_website>
43
+ <show_in_store>1</show_in_store>
44
+ </enabled>
45
+ </fields>
46
+ </general>
47
+ </groups>
48
+ </dwd_cmsmenu>
49
+ </sections>
50
+ </config>
app/code/community/DwD/CmsMenu/sql/cmsmenu_setup/mysql4-install-0.1.0.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * DwD-CmsMenu - Magento Extension
6
+ *
7
+ * @copyright Copyright (c) 2015 DwDesigner Inc. (http://www.dwdeveloper.com/)
8
+ * @author Damian A. Pastorini - damian.pastorini@dwdeveloper.com
9
+ *
10
+ */
11
+
12
+ $installer = $this;
13
+ $installer->startSetup();
14
+
15
+ // cmsmenu table:
16
+
17
+ $sql=<<<SQLTEXT
18
+ CREATE TABLE `cmsmenu` (
19
+ `id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
20
+ `cms_page_id` SMALLINT(6) NOT NULL,
21
+ `show_in_menu` SMALLINT(6) NOT NULL,
22
+ `child_of` VARCHAR(255) NULL DEFAULT NULL,
23
+ `add_before` VARCHAR(255) NULL DEFAULT NULL,
24
+ `menu_item_title` VARCHAR(255) NULL DEFAULT NULL,
25
+ PRIMARY KEY (`id`),
26
+ UNIQUE INDEX `cms_page_id` (`cms_page_id`),
27
+ CONSTRAINT `FK_cmsmenu_cms_page` FOREIGN KEY (`cms_page_id`) REFERENCES `cms_page` (`page_id`)
28
+ )
29
+ ENGINE=InnoDB;
30
+ SQLTEXT;
31
+
32
+ $installer->run($sql);
33
+
34
+ $installer->endSetup();
app/etc/modules/DwD_CmsMenu.xml ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ *
5
+ * DwD-CmsMenu - Magento Extension
6
+ *
7
+ * @copyright Copyright (c) 2015 DwDesigner Inc. (http://www.dwdeveloper.com/)
8
+ * @author Damian A. Pastorini - damian.pastorini@dwdeveloper.com
9
+ *
10
+ */
11
+ -->
12
+ <config>
13
+ <modules>
14
+ <DwD_CmsMenu>
15
+ <active>true</active>
16
+ <codePool>community</codePool>
17
+ </DwD_CmsMenu>
18
+ </modules>
19
+ </config>
package.xml ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>DwD_CmsMenu</name>
4
+ <version>0.1.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/afl-3.0.php">Academic Free License (AFL 3.0)</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Include and manage CMS pages link in the top navigation.</summary>
10
+ <description>&lt;h1&gt;DwDeveloper - CMS Menu&lt;/h1&gt;&#xD;
11
+ &lt;h2&gt;Features&lt;/h2&gt;&#xD;
12
+ &lt;p&gt;DwD - CMS Menu allows you to include CMS pages links and set them in any order in the top navigation.&lt;/p&gt;&#xD;
13
+ &lt;h3&gt;About the extension&lt;/h3&gt;&#xD;
14
+ &lt;p&gt;&#xD;
15
+ The extension will create a new table to save the pages menu configuration and include the links with an observer.&lt;br/&gt;&#xD;
16
+ &lt;/p&gt;&#xD;
17
+ &lt;p&gt;&#xD;
18
+ Extension features:&lt;br/&gt;&#xD;
19
+ &lt;ul&gt;&#xD;
20
+ &lt;li&gt;Enable / disable the extension.&lt;/li&gt;&#xD;
21
+ &lt;li&gt;Configure a custom label for the page link in the menu.&lt;/li&gt;&#xD;
22
+ &lt;li&gt;Set the menu item order.&lt;/li&gt;&#xD;
23
+ &lt;/ul&gt;&#xD;
24
+ &lt;/p&gt;&#xD;
25
+ &lt;h3&gt;How this extension will help you?&lt;/h3&gt;&#xD;
26
+ &lt;p&gt;&#xD;
27
+ Dis you ever try to include a CMS page in the top menu?&lt;br/&gt;&#xD;
28
+ There's nothing easy on that and you will read about two common options: follow around 20 steps in the Magento Admin features (that will involve creata a category, a custom redirect, etc.), or do it by code.&lt;br/&gt;&#xD;
29
+ This will make everything easier and you will get everything working in a few clicks.&#xD;
30
+ &lt;/p&gt;&#xD;
31
+ &lt;h2&gt;How it works? Use it in simple steps:&lt;/h2&gt;&#xD;
32
+ &lt;ul&gt;&#xD;
33
+ &lt;li&gt;Go to System / Configuration / DwD Extensions / CMS Menu&lt;/li&gt;&#xD;
34
+ &lt;li&gt;Enable the extension&lt;/li&gt;&#xD;
35
+ &lt;li&gt;Save the configuration&lt;/li&gt;&#xD;
36
+ &lt;li&gt;Go to CMS / CMS Pages&lt;/li&gt;&#xD;
37
+ &lt;li&gt;Edit the page you want to include in the top menu&lt;/li&gt;&#xD;
38
+ &lt;li&gt;Specify the top menu item configuration.&lt;/li&gt;&#xD;
39
+ &lt;li&gt;Save the CMS page&lt;/li&gt;&#xD;
40
+ &lt;li&gt;Enjoy!&lt;/li&gt;&#xD;
41
+ &lt;/ul&gt;&#xD;
42
+ &lt;h2&gt;Supported versions&lt;/h2&gt;&#xD;
43
+ &lt;p&gt;Magento 1.8 to 1.9.x.&lt;/p&gt;&#xD;
44
+ &lt;h2&gt;Support&lt;/h2&gt;&#xD;
45
+ &lt;p&gt;For support, contact us at &lt;a href="mailto:info@dwdeveloper.com"&gt;info@dwdeveloper.com&lt;/a&gt;&lt;/p&gt;</description>
46
+ <notes>First release.</notes>
47
+ <authors><author><name>Damian A. Pastorini</name><user>MAG002087848</user><email>damian.pastorini@dwdeveloper.com</email></author></authors>
48
+ <date>2015-09-13</date>
49
+ <time>18:49:49</time>
50
+ <contents><target name="mageetc"><dir name="modules"><file name="DwD_CmsMenu.xml" hash="9b1288160fc81a13f811056ca9f49123"/></dir></target><target name="magecommunity"><dir name="DwD"><dir name="CmsMenu"><dir name="Block"><dir name="Adminhtml"><dir name="Cms"><dir name="Page"><dir name="Edit"><dir name="Tab"><file name="Content.php" hash="3694e6d33bae1c5db9ca91163523f357"/></dir></dir></dir></dir></dir><dir name="Page"><dir name="Html"><dir name="Topmenu"><file name="Observer.php" hash="fd1a67f069d30dd2e72a89fd2468c95f"/></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="531295ed2a3e9dba53f54f828f9604d4"/></dir><dir name="Model"><file name="Cmsmenu.php" hash="27a1044475f1a225142baa025051b5fb"/><dir name="Mysql4"><dir name="Cmsmenu"><file name="Collection.php" hash="d53ae01bcbec3719de7c5f2653b2790c"/></dir><file name="Cmsmenu.php" hash="f317ca72b5de8d0cf7a018b4deb8cdb8"/></dir><file name="Observer.php" hash="d54cb67ddbb1f7edc653ab21f094898d"/></dir><dir name="etc"><file name="adminhtml.xml" hash="a47c8fe2ed9bdcc5a91595d9f633397e"/><file name="config.xml" hash="1e125384ab70caa64a32edb4ad9839a6"/><file name="system.xml" hash="451a0ce59858b7d11d2606ae69580262"/></dir><dir name="sql"><dir name="cmsmenu_setup"><file name="mysql4-install-0.1.0.php" hash="73444ae647df8d06aed1530be2d85621"/></dir></dir></dir></dir></target></contents>
51
+ <compatible/>
52
+ <dependencies><required><php><min>5.3.0</min><max>6.0.0</max></php></required></dependencies>
53
+ </package>