HusseyCoding_CmsMenuContent - Version 1.0.5

Version Notes

Fixed losing block order on cms edit page load

Download this release

Release Info

Developer Hussey Coding
Extension HusseyCoding_CmsMenuContent
Version 1.0.5
Comparing to
See all releases


Version 1.0.5

app/code/community/HusseyCoding/CmsMenuContent/Block/Cms/Block/Edit/AdminhtmlForm.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class HusseyCoding_CmsMenuContent_Block_Cms_Block_Edit_AdminhtmlForm extends Mage_Adminhtml_Block_Cms_Block_Edit_Form
3
+ {
4
+ protected function _prepareForm()
5
+ {
6
+ parent::_prepareForm();
7
+
8
+ $model = Mage::registry('cms_block');
9
+
10
+ $form = $this->getForm();
11
+
12
+ $menufieldset = $form->addFieldset('menucontent_fieldset', array(
13
+ 'legend' => Mage::helper('cms')->__('Configure Link Display'),
14
+ 'class' => 'fieldset-wide',
15
+ 'comment' => Mage::helper('cms')->__('Configure how this block will display on CMS pages configured as menu pages.')
16
+ ));
17
+
18
+ $menufieldset->addField('use_in_menu_page', 'select', array(
19
+ 'label' => Mage::helper('cms')->__('Enabled For Menu Pages'),
20
+ 'title' => Mage::helper('cms')->__('Enabled For Menu Pages'),
21
+ 'name' => 'use_in_menu_page',
22
+ 'options' => array(
23
+ '1' => Mage::helper('cms')->__('Yes'),
24
+ '0' => Mage::helper('cms')->__('No'),
25
+ )
26
+ ));
27
+
28
+ $menufieldset->addField('link_text', 'text', array(
29
+ 'name' => 'link_text',
30
+ 'label' => Mage::helper('cms')->__('Link Text'),
31
+ 'title' => Mage::helper('cms')->__('Link Text'),
32
+ 'note' => Mage::helper('cms')->__('Block title is used by default')
33
+ ));
34
+
35
+ $form->setValues($model->getData());
36
+
37
+ return $this;
38
+ }
39
+ }
app/code/community/HusseyCoding/CmsMenuContent/Block/Cms/Page/Edit/Tab/Cmsselect.php ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class HusseyCoding_CmsMenuContent_Block_Cms_Page_Edit_Tab_Cmsselect
3
+ extends Mage_Adminhtml_Block_Widget_Form
4
+ implements Mage_Adminhtml_Block_Widget_Tab_Interface
5
+ {
6
+ protected function _prepareForm()
7
+ {
8
+ $model = Mage::registry('cms_page');
9
+
10
+ $form = new Varien_Data_Form();
11
+
12
+ $form->setHtmlIdPrefix('menu_');
13
+
14
+ $menufieldset = $form->addFieldset('cmsmenucontentpages_fieldset', array(
15
+ 'legend' => Mage::helper('cms')->__('Configure Menu Content'),
16
+ 'comment' => Mage::helper('cms')->__('Configure this page to display a menu of static block content.')
17
+ ));
18
+
19
+ $menufieldset->addField('is_menu_page', 'select', array(
20
+ 'name' => 'is_menu_page',
21
+ 'label' => Mage::helper('cms')->__('Menu Page'),
22
+ 'title' => Mage::helper('cms')->__('Menu Page'),
23
+ 'note' => Mage::helper('cms')->__('Use {{menucontent}} in content to set links position'),
24
+ 'values' => array(
25
+ '1' => Mage::helper('cms')->__('Enabled'),
26
+ '0' => Mage::helper('cms')->__('Disabled'),
27
+ )
28
+ ));
29
+
30
+ $menufieldset->addField('block_order', 'hidden', array(
31
+ 'name' => 'block_order',
32
+ 'value' => ''
33
+ ));
34
+
35
+ $menufieldset->addField('menu_items', 'multiselect', array(
36
+ 'name' => 'menu_items',
37
+ 'label' => Mage::helper('cms')->__('Pages in Menu'),
38
+ 'title' => Mage::helper('cms')->__('Pages in Menu'),
39
+ 'values' => Mage::getSingleton('cmsmenucontent/system_config_source_cmsmenucontent')->toOptionArray()
40
+ ));
41
+
42
+ $linkfieldset = $form->addFieldset('cmsmenucontentlinks_fieldset', array(
43
+ 'legend' => Mage::helper('cms')->__('Configure Link Display'),
44
+ 'comment' => Mage::helper('cms')->__('Optionally style the display of the menu links. Use HTML Colour e.g. 444444.')
45
+ ));
46
+
47
+ $linkfieldset->addField('link_colour', 'text', array(
48
+ 'name' => 'link_colour',
49
+ 'label' => Mage::helper('cms')->__('Link Colour'),
50
+ 'title' => Mage::helper('cms')->__('Link Colour')
51
+ ));
52
+
53
+ $linkfieldset->addField('hover_colour', 'text', array(
54
+ 'name' => 'hover_colour',
55
+ 'label' => Mage::helper('cms')->__('Link Hover Colour'),
56
+ 'title' => Mage::helper('cms')->__('Link Hover Colour')
57
+ ));
58
+
59
+ $linkfieldset->addField('active_colour', 'text', array(
60
+ 'name' => 'active_colour',
61
+ 'label' => Mage::helper('cms')->__('Link Active Colour'),
62
+ 'title' => Mage::helper('cms')->__('Link Active Colour')
63
+ ));
64
+
65
+ $linkfieldset->addField('ahover_colour', 'text', array(
66
+ 'name' => 'ahover_colour',
67
+ 'label' => Mage::helper('cms')->__('Link Active Hover Colour'),
68
+ 'title' => Mage::helper('cms')->__('Link Active Hover Colour')
69
+ ));
70
+
71
+ $form->setValues($model->getData());
72
+ $this->setForm($form);
73
+
74
+ return parent::_prepareForm();
75
+ }
76
+
77
+ public function getTabLabel()
78
+ {
79
+ return Mage::helper('cms')->__('Menu Content');
80
+ }
81
+
82
+ public function getTabTitle()
83
+ {
84
+ return Mage::helper('cms')->__('Menu Content');
85
+ }
86
+
87
+ public function canShowTab()
88
+ {
89
+ return true;
90
+ }
91
+
92
+ public function isHidden()
93
+ {
94
+ return false;
95
+ }
96
+
97
+ protected function _isAllowedAction($action)
98
+ {
99
+ return Mage::getSingleton('admin/session')->isAllowed('cms/page/' . $action);
100
+ }
101
+ }
app/code/community/HusseyCoding/CmsMenuContent/Helper/Data.php ADDED
@@ -0,0 +1,130 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class HusseyCoding_CmsMenuContent_Helper_Data extends Mage_Core_Helper_Abstract
3
+ {
4
+ public $css;
5
+ public $js;
6
+
7
+ public function addBlocks($blocks, $content, $page)
8
+ {
9
+ $blocks = $this->getValidateBlocks($blocks, $page->getStoreId());
10
+ $linkcolour = $this->validateHtmlColour($page->getLinkColour());
11
+ $hovercolour = $this->validateHtmlColour($page->getHoverColour());
12
+ $activecolour = $this->validateHtmlColour($page->getActiveColour());
13
+ $ahovercolour = $this->validateHtmlColour($page->getAhoverColour());
14
+
15
+ if ($blocks):
16
+ $itemshtml = $this->getItemsHtml($blocks);
17
+
18
+ $html = $this->getItemsCss($linkcolour, $hovercolour, $activecolour, $ahovercolour);
19
+
20
+ $html .= '<div class="cmsmenucontent_container">';
21
+
22
+ $html .= '<div class="cmsmenucontent_menu">';
23
+ $html .= $itemshtml['linkshtml'];
24
+ $html .= '</div>';
25
+
26
+ $html .= '<div class="cmsmenucontent_content">';
27
+ $html .= $itemshtml['contenthtml'];
28
+ $html .= '</div>';
29
+
30
+ $html .= '</div>';
31
+
32
+ $html .= $this->getItemsJs($blocks);
33
+
34
+ $html = str_replace('{{menucontent}}', $html, $content);
35
+
36
+ return $html;
37
+ endif;
38
+
39
+ return str_replace('{{menucontent}}', '', $content);
40
+ }
41
+
42
+ private function getValidateBlocks($blocks, $pagescope)
43
+ {
44
+ $return = array();
45
+ $cmsall = in_array('0', $pagescope);
46
+ foreach ($blocks as $block):
47
+ $block = Mage::getModel('cms/block')->load((int) $block);
48
+ if ($block):
49
+ if ($block->getIsActive() && $block->getUseInMenuPage()):
50
+ if (!$cmsall):
51
+ $blockscope = $block->getStoreId();
52
+ $compare = array_diff($blockscope, $pagescope);
53
+ if (count($blockscope) > count($compare) || in_array('0', $blockscope)):
54
+ $return[] = $block;
55
+ endif;
56
+ else:
57
+ $return[] = $block;
58
+ endif;
59
+ endif;
60
+ endif;
61
+ endforeach;
62
+
63
+ return $return;
64
+ }
65
+
66
+ public function validateHtmlColour($colour)
67
+ {
68
+ if (strpos($colour, '#') === 0):
69
+ $colour = substr($colour, 1);
70
+ endif;
71
+ if (preg_match('/^[0-9a-fA-F]+$/', $colour)):
72
+ if (strlen($colour) == 6 || strlen($colour) == 3):
73
+ return '#' . $colour;
74
+ endif;
75
+ endif;
76
+
77
+ return false;
78
+ }
79
+
80
+ private function getItemsHtml($blocks)
81
+ {
82
+ $menuhtml = array();
83
+ $contenthtml = array();
84
+ foreach ($blocks as $key => $block):
85
+ $key++;
86
+ $title = $this->getBlockMenuTitle($block);
87
+ $menuhtml[] = '<a class="blocklink" id="blocklink_' . $key . '" href="javascript:void(0)">' . $title . '</a>';
88
+ $contenthtml[] = '<div class="blockcontent" id="blockcontent_' . $key . '">' . $block->getContent() . '</div>';
89
+ endforeach;
90
+
91
+ $menuhtml = implode('', $menuhtml);
92
+ $contenthtml = implode('', $contenthtml);
93
+
94
+ return array('linkshtml' => $menuhtml, 'contenthtml' => $contenthtml);
95
+ }
96
+
97
+ public function getBlockMenuTitle($block)
98
+ {
99
+ return $block->getLinkText() ? $block->getLinkText() : $block->getTitle();
100
+ }
101
+
102
+ private function getItemsCss($linkcolour, $hovercolour, $activecolour, $ahovercolour)
103
+ {
104
+ $css = '';
105
+ if ($linkcolour || $hovercolour || $activecolour):
106
+ $css .= '<style type="text/css">';
107
+ if ($linkcolour) $css .= ' .cmsmenucontent_container .cmsmenucontent_menu a.blocklink { color:' . $linkcolour . '; }';
108
+ if ($hovercolour) $css .= ' .cmsmenucontent_container .cmsmenucontent_menu a.blocklink:hover { color:' . $hovercolour . '; }';
109
+ if ($activecolour) $css .= ' .cmsmenucontent_container .cmsmenucontent_menu a.blocklink_active { color:' . $activecolour . '; }';
110
+ if ($ahovercolour) $css .= ' .cmsmenucontent_container .cmsmenucontent_menu a.blocklink_active:hover { color:' . $ahovercolour . '; }';
111
+ $css .= ' </style>';
112
+ endif;
113
+
114
+ return $css;
115
+ }
116
+
117
+ private function getItemsJs($blocks)
118
+ {
119
+ $js = '<script type="text/javascript">';
120
+ $js .= ' var thismenucontent = new menucontent();';
121
+ $js .= ' thismenucontent.menuitems = {};';
122
+ foreach ($blocks as $key => $blocks):
123
+ $key++;
124
+ $js .= ' thismenucontent.menuitems.blocklink_' . $key . ' = "blockcontent_' . $key . '";';
125
+ endforeach;
126
+ $js .= ' </script>';
127
+
128
+ return $js;
129
+ }
130
+ }
app/code/community/HusseyCoding/CmsMenuContent/Model/Observer.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class HusseyCoding_CmsMenuContent_Model_Observer
3
+ {
4
+ public function adminhtmlCmsPageSaveBefore($observer)
5
+ {
6
+ $page = $observer->getObject();
7
+ $page->setMenuItems(implode(',', $page->getMenuItems()));
8
+ }
9
+
10
+ public function adminhtmlCmsPageLoadAfter($observer)
11
+ {
12
+ $page = $observer->getObject();
13
+ $page->setMenuItems(explode(',', $page->getMenuItems()));
14
+ }
15
+
16
+ public function frontendCmsPageRender($observer)
17
+ {
18
+ $page = $observer->getPage();
19
+ if ($page->getIsMenuPage() && $page->getMenuItems()):
20
+ $content = $page->getContent();
21
+ $blocks = $page->getBlockOrder();
22
+ if (strpos($content, '{{menucontent}}') !== false && $blocks):
23
+ $blocks = explode(',', $blocks);
24
+ $content = Mage::helper('cmsmenucontent')->addBlocks($blocks, $content, $page);
25
+ $page->setContent($content);
26
+ endif;
27
+ else:
28
+ $content = $page->getContent();
29
+ if (strpos($content, '{{menucontent}}') !== false):
30
+ $content = str_replace('{{menucontent}}', '', $content);
31
+ $page->setContent($content);
32
+ endif;
33
+ endif;
34
+ }
35
+ }
app/code/community/HusseyCoding/CmsMenuContent/Model/System/Config/Source/Cmsmenucontent.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class HusseyCoding_CmsMenuContent_Model_System_Config_Source_Cmsmenucontent
3
+ {
4
+ public function toOptionArray()
5
+ {
6
+ $selects = array();
7
+ $pages = Mage::getModel('cms/block')->getCollection();
8
+
9
+ $scope = Mage::app()->getRequest()->getParam('page_id');
10
+ $scope = Mage::getModel('cms/page')->load($scope);
11
+ $scope = $scope->getStoreId();
12
+
13
+ $resource = Mage::getSingleton('core/resource');
14
+ $select = $pages->getSelect();
15
+ $select
16
+ ->where('main_table.is_active = ?', 1)
17
+ ->where('main_table.use_in_menu_page = ?', 1);
18
+
19
+ if (!in_array('0', $scope)):
20
+ $blockscope = $scope;
21
+ $blockscope[] = '0';
22
+ $select
23
+ ->join(
24
+ array('store' => $resource->getTableName('cms/block_store')),
25
+ 'main_table.block_id = store.block_id',
26
+ array('store_id')
27
+ )
28
+ ->where('store.store_id IN (?)', $blockscope)
29
+ ->group('block_id');
30
+ endif;
31
+
32
+ foreach ($pages as $page):
33
+ $selects[] = array('value' => $page->getId(), 'label' => $page->getTitle());
34
+ endforeach;
35
+
36
+ return $selects;
37
+ }
38
+ }
app/code/community/HusseyCoding/CmsMenuContent/etc/adminhtml.xml ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <acl>
4
+ <resources>
5
+ <all>
6
+ <title>Allow Everything</title>
7
+ </all>
8
+ <admin>
9
+ <children>
10
+ <system>
11
+ <children>
12
+ <config>
13
+ <children>
14
+ <cmsmenucontent module="cmsmenucontent">
15
+ <title>Cms Menu Content</title>
16
+ </cmsmenucontent>
17
+ </children>
18
+ </config>
19
+ </children>
20
+ </system>
21
+ </children>
22
+ </admin>
23
+ </resources>
24
+ </acl>
25
+ </config>
app/code/community/HusseyCoding/CmsMenuContent/etc/config.xml ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <HusseyCoding_CmsMenuContent>
5
+ <version>1.0.5</version>
6
+ </HusseyCoding_CmsMenuContent>
7
+ </modules>
8
+ <global>
9
+ <models>
10
+ <cmsmenucontent>
11
+ <class>HusseyCoding_CmsMenuContent_Model</class>
12
+ </cmsmenucontent>
13
+ </models>
14
+ <blocks>
15
+ <cmsmenucontent>
16
+ <class>HusseyCoding_CmsMenuContent_Block</class>
17
+ </cmsmenucontent>
18
+ <adminhtml>
19
+ <rewrite>
20
+ <cms_block_edit_form>HusseyCoding_CmsMenuContent_Block_Cms_Block_Edit_AdminhtmlForm</cms_block_edit_form>
21
+ </rewrite>
22
+ </adminhtml>
23
+ </blocks>
24
+ <helpers>
25
+ <cmsmenucontent>
26
+ <class>HusseyCoding_CmsMenuContent_Helper</class>
27
+ </cmsmenucontent>
28
+ </helpers>
29
+ <resources>
30
+ <cmsmenucontent_setup>
31
+ <setup>
32
+ <module>HusseyCoding_CmsMenuContent</module>
33
+ </setup>
34
+ <connection>
35
+ <use>core_setup</use>
36
+ </connection>
37
+ </cmsmenucontent_setup>
38
+ </resources>
39
+ </global>
40
+ <adminhtml>
41
+ <layout>
42
+ <updates>
43
+ <cmsmenucontent>
44
+ <file>cmsmenucontent.xml</file>
45
+ </cmsmenucontent>
46
+ </updates>
47
+ </layout>
48
+ <events>
49
+ <cms_page_save_before>
50
+ <observers>
51
+ <adminhtml_cms_page_save_before_cmsmenucontent>
52
+ <type>singleton</type>
53
+ <class>cmsmenucontent/observer</class>
54
+ <method>adminhtmlCmsPageSaveBefore</method>
55
+ </adminhtml_cms_page_save_before_cmsmenucontent>
56
+ </observers>
57
+ </cms_page_save_before>
58
+ <cms_page_load_after>
59
+ <observers>
60
+ <adminhtml_cms_page_load_after_cmsmenucontent>
61
+ <type>singleton</type>
62
+ <class>cmsmenucontent/observer</class>
63
+ <method>adminhtmlCmsPageLoadAfter</method>
64
+ </adminhtml_cms_page_load_after_cmsmenucontent>
65
+ </observers>
66
+ </cms_page_load_after>
67
+ </events>
68
+ </adminhtml>
69
+ <frontend>
70
+ <layout>
71
+ <updates>
72
+ <cmsmenucontent>
73
+ <file>cmsmenucontent.xml</file>
74
+ </cmsmenucontent>
75
+ </updates>
76
+ </layout>
77
+ <events>
78
+ <cms_page_render>
79
+ <observers>
80
+ <adminhtml_cms_page_render_cmsmenucontent>
81
+ <type>singleton</type>
82
+ <class>cmsmenucontent/observer</class>
83
+ <method>frontendCmsPageRender</method>
84
+ </adminhtml_cms_page_render_cmsmenucontent>
85
+ </observers>
86
+ </cms_page_render>
87
+ </events>
88
+ </frontend>
89
+ </config>
app/code/community/HusseyCoding/CmsMenuContent/etc/system.xml ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <sections>
4
+ <cmsmenucontent translate="label">
5
+ <label>CMS Menu Content</label>
6
+ <tab>husseycoding</tab>
7
+ <frontend_type>text</frontend_type>
8
+ <sort_order>1</sort_order>
9
+ <show_in_default>1</show_in_default>
10
+ <show_in_website>1</show_in_website>
11
+ <show_in_store>1</show_in_store>
12
+ <groups>
13
+ <information translate="label">
14
+ <label>Configuration</label>
15
+ <frontend_type>text</frontend_type>
16
+ <sort_order>1</sort_order>
17
+ <show_in_default>1</show_in_default>
18
+ <show_in_website>1</show_in_website>
19
+ <show_in_store>1</show_in_store>
20
+ <comment>Configuration settings can be found on the 'Menu Content' tab while editing a CMS page, and under the 'Configure Link Display' section while editing a static block.</comment>
21
+ </information>
22
+ </groups>
23
+ </cmsmenucontent>
24
+ </sections>
25
+ </config>
app/code/community/HusseyCoding/CmsMenuContent/sql/cmsmenucontent_setup/mysql4-install-1.0.0.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $installer = $this;
3
+
4
+ $installer->startSetup();
5
+
6
+ $installer->run("
7
+ ALTER TABLE {$this->getTable('cms/page')}
8
+ ADD `is_menu_page` TINYINT NOT NULL DEFAULT '0',
9
+ ADD `menu_items` TEXT NULL DEFAULT NULL,
10
+ ADD `link_colour` TINYTEXT NULL DEFAULT NULL,
11
+ ADD `hover_colour` TINYTEXT NULL DEFAULT NULL,
12
+ ADD `active_colour` TINYTEXT NULL DEFAULT NULL,
13
+ ADD `ahover_colour` TINYTEXT NULL DEFAULT NULL,
14
+ ADD `block_order` TEXT NULL DEFAULT NULL
15
+ ");
16
+
17
+ $installer->run("
18
+ ALTER TABLE {$this->getTable('cms/block')}
19
+ ADD `use_in_menu_page` TINYINT NOT NULL DEFAULT '0',
20
+ ADD `link_text` TEXT NULL DEFAULT NULL
21
+ ");
22
+
23
+ $installer->endSetup();
app/code/community/HusseyCoding/Common/etc/system.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <tabs>
4
+ <husseycoding translate="label">
5
+ <label>Hussey Coding</label>
6
+ <sort_order>500</sort_order>
7
+ </husseycoding>
8
+ </tabs>
9
+ </config>
app/design/adminhtml/default/default/layout/cmsmenucontent.xml ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout>
3
+ <adminhtml_cms_page_edit>
4
+ <reference name="cms_page_edit_tabs">
5
+ <block type="cmsmenucontent/cms_page_edit_tab_cmsselect" name="cms_page_edit_tab_cmsselect" />
6
+ <action method="addTab"><name>cmsmenucontent_section</name><block>cms_page_edit_tab_cmsselect</block></action>
7
+ </reference>
8
+ <reference name="head">
9
+ <action method="addItem">
10
+ <type>skin_js</type>
11
+ <name>cmsmenucontent/js/cmsmenucontent.js</name>
12
+ </action>
13
+ </reference>
14
+ </adminhtml_cms_page_edit>
15
+ </layout>
app/design/frontend/base/default/layout/cmsmenucontent.xml ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <cms_page>
4
+ <reference name="head">
5
+ <action method="addItem">
6
+ <type>skin_js</type>
7
+ <name>js/cmsmenucontent.js</name>
8
+ </action>
9
+ <action method="addItem">
10
+ <type>skin_css</type>
11
+ <name>css/cmsmenucontent.css</name>
12
+ </action>
13
+ </reference>
14
+ </cms_page>
15
+ </layout>
app/etc/modules/HusseyCoding_CmsMenuContent.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <HusseyCoding_CmsMenuContent>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </HusseyCoding_CmsMenuContent>
8
+ </modules>
9
+ </config>
app/etc/modules/HusseyCoding_Common.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <HusseyCoding_Common>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </HusseyCoding_Common>
8
+ </modules>
9
+ </config>
package.xml ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>HusseyCoding_CmsMenuContent</name>
4
+ <version>1.0.5</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL)</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Adds tab style content switching to Magento CMS pages.</summary>
10
+ <description>This fully search engine optimised (SEO) extension allows you to greatly condense the number of CMS pages you need by quickly and easily including any number of static blocks on a CMS page with customisable links to switch between block content.&#xD;
11
+ &#xD;
12
+ This allows you to have a high volume of information on only a few pages while keeping content highly readable and accessible by the customer.</description>
13
+ <notes>Fixed losing block order on cms edit page load</notes>
14
+ <authors><author><name>Hussey Coding</name><user>husseycoding</user><email>info@husseycoding.co.uk</email></author></authors>
15
+ <date>2015-08-16</date>
16
+ <time>05:50:02</time>
17
+ <contents><target name="magecommunity"><dir name="HusseyCoding"><dir name="CmsMenuContent"><dir name="Block"><dir name="Cms"><dir name="Block"><dir name="Edit"><file name="AdminhtmlForm.php" hash="8b3d9b9efc2fb0196170243f1d834ddc"/></dir></dir><dir name="Page"><dir name="Edit"><dir name="Tab"><file name="Cmsselect.php" hash="203884175c84b904d888d2fa01aeb02b"/></dir></dir></dir></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="e0b337d009017cd85850fa4f435908cf"/><file name="config.xml" hash="6ceb112dd2ad665ebdf02b261303b7b1"/><file name="system.xml" hash="a406ecf3c9587d5b01d8c1948ff2a226"/></dir><dir name="Helper"><file name="Data.php" hash="83dfe3a1035e6bdba0ce28341e5d8e9f"/></dir><dir name="Model"><file name="Observer.php" hash="1148fec36c6ee12c6e1fbd6b9c80b371"/><dir name="System"><dir name="Config"><dir name="Source"><file name="Cmsmenucontent.php" hash="94a74f45a770f313061cdacd2befeef3"/></dir></dir></dir></dir><dir name="sql"><dir name="cmsmenucontent_setup"><file name="mysql4-install-1.0.0.php" hash="d0381661e97eaf679ea945bd7a602952"/></dir></dir></dir><dir name="Common"><dir name="etc"><file name="system.xml" hash="6c9ba9f227b9adfc9abf97f17b46fdbf"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="HusseyCoding_CmsMenuContent.xml" hash="83437e316b1a2960bed43874190e3643"/><file name="HusseyCoding_Common.xml" hash="31e82d3d9b3179c2fa9e002f9669da47"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="cmsmenucontent.xml" hash="526a2c79ead0c597b49381f001b9f973"/></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="cmsmenucontent.xml" hash="c97897fa5b2aed04a1322c2e993c2db6"/></dir></dir></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="cmsmenucontent"><dir name="js"><file name="cmsmenucontent.js" hash="e730f983de79909158b56e7fcab67bf6"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="js"><file name="cmsmenucontent.js" hash="e7170f638a49b44c8f3844fee890e90a"/></dir><dir name="css"><file name="cmsmenucontent.css" hash="dd1d4fe0a289497c765dded798b1186f"/></dir></dir></dir></dir></target></contents>
18
+ <compatible/>
19
+ <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
20
+ </package>
skin/adminhtml/default/default/cmsmenucontent/js/cmsmenucontent.js ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var selected = Class.create({
2
+ initialize: function() {
3
+ this.userselected = $F("menu_block_order").split(",");
4
+ this.getText();
5
+ Event.observe($("menu_menu_items"), "change", this.updateForm.bindAsEventListener(this));
6
+ $("menu_menu_items").up("tr").insert({ after: '<tr><td class="label">Block Display Order</td><td id="displayblockorder" class="value"></td></tr>' });
7
+ this.outputOrder();
8
+ },
9
+ addColumn: function(id) {
10
+ if (this.userselected.indexOf(id) == -1) {
11
+ this.userselected.push(id);
12
+ }
13
+ },
14
+ removeColumn: function(id) {
15
+ var count = 0;
16
+ this.userselected.each(function(s) {
17
+ if (s == id) {
18
+ this.userselected.splice(count, 1);
19
+ throw $break;
20
+ }
21
+ count++;
22
+ }.bind(this));
23
+ },
24
+ updateForm: function() {
25
+ this.checkForm();
26
+ this.outputOrder();
27
+ },
28
+ checkForm: function() {
29
+ var selectedoptions = {};
30
+ this.userselected.each(function(s) {
31
+ selectedoptions[s] = true;
32
+ }.bind(this));
33
+ for (var i = 0; i < $("menu_menu_items").options.length; i++) {
34
+ var value = $("menu_menu_items").options[i].value;
35
+ if (selectedoptions[value] && !$("menu_menu_items").options[i].selected) {
36
+ this.removeColumn(value);
37
+ } else if (!selectedoptions[value] && $("menu_menu_items").options[i].selected) {
38
+ this.addColumn(value);
39
+ }
40
+ }
41
+ },
42
+ getText: function() {
43
+ this.valuetext = {};
44
+ for (var i = 0; i < $("menu_menu_items").options.length; i++) {
45
+ this.valuetext[$("menu_menu_items").options[i].value] = $("menu_menu_items").options[i].text;
46
+ }
47
+ },
48
+ outputOrder: function() {
49
+ var html = new Array();
50
+ var hidden = new Array();
51
+ this.userselected.each(function(s) {
52
+ html.push(this.valuetext[s]);
53
+ hidden.push(s);
54
+ }.bind(this));
55
+ hidden = hidden.join(",");
56
+ html = html.join("<br />");
57
+ $("menu_block_order").value = hidden;
58
+ $("displayblockorder").update(html);
59
+ }
60
+ });
61
+
62
+ document.observe("dom:loaded", function() {
63
+ var selecteditems = new selected();
64
+ });
skin/frontend/base/default/css/cmsmenucontent.css ADDED
@@ -0,0 +1,2 @@
 
 
1
+ .cmsmenucontent_container .cmsmenucontent_menu a { padding-bottom:4px; display:block; }
2
+ .cmsmenucontent_container .cmsmenucontent_menu { margin-bottom:16px; }
skin/frontend/base/default/js/cmsmenucontent.js ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var menucontent = Class.create({
2
+ afterInit: function() {
3
+ this.initMenuItems();
4
+ this.addObservers();
5
+ this.bookmarkSwitch();
6
+ },
7
+ initMenuItems: function() {
8
+ var count = 0;
9
+ $H(this.menuitems).each(function(item) {
10
+ if (count == 0) {
11
+ $(item.key).removeClassName("blocklink")
12
+ $(item.key).addClassName("blocklink_active")
13
+ $(item.value).show();
14
+ } else {
15
+ $(item.value).hide();
16
+ }
17
+ count++;
18
+ });
19
+ },
20
+ addObservers: function() {
21
+ $H(this.menuitems).each(function(item) {
22
+ $(item.key).observe("click", function(e) {
23
+ this.displayContent(e.target.id);
24
+ }.bindAsEventListener(this));
25
+ }.bind(this));
26
+ },
27
+ displayContent: function(el) {
28
+ $H(this.menuitems).each(function(item) {
29
+ if (item.key == el) {
30
+ $(item.key).removeClassName("blocklink")
31
+ $(item.key).addClassName("blocklink_active")
32
+ $(item.value).show();
33
+ } else {
34
+ $(item.key).removeClassName("blocklink_active")
35
+ $(item.key).addClassName("blocklink")
36
+ $(item.value).hide();
37
+ }
38
+ });
39
+ },
40
+ bookmarkSwitch: function() {
41
+ if (window.location.href.indexOf("#") != -1) {
42
+ var argument = window.location.href.split("#").pop();
43
+ if (argument) {
44
+ var el = $("blocklink_" + argument);
45
+ if (el) {
46
+ this.displayContent(el.id);
47
+ }
48
+ }
49
+ }
50
+ }
51
+ });
52
+
53
+ document.observe("dom:loaded", function() {
54
+ if (typeof(thismenucontent) == "object") {
55
+ thismenucontent.afterInit();
56
+ }
57
+ });