Version Notes
+ integrate small columns
Download this release
Release Info
Developer | Magento Core Team |
Extension | wp_custom_menu |
Version | 1.2.5 |
Comparing to | |
See all releases |
Version 1.2.5
- app/code/local/WP/CustomMenu/Block/Navigation.php +216 -0
- app/code/local/WP/CustomMenu/Helper/Data.php +6 -0
- app/code/local/WP/CustomMenu/etc/adminhtml.xml +23 -0
- app/code/local/WP/CustomMenu/etc/config.xml +65 -0
- app/code/local/WP/CustomMenu/etc/system.xml +117 -0
- app/design/frontend/base/default/layout/custommenu.xml +12 -0
- app/design/frontend/base/default/template/custommenu/top.phtml +18 -0
- app/etc/modules/WP_CustomMenu.xml +9 -0
- package.xml +18 -0
- skin/frontend/base/default/css/custommenu.css +49 -0
- skin/frontend/base/default/js/custommenu.js +61 -0
app/code/local/WP/CustomMenu/Block/Navigation.php
ADDED
@@ -0,0 +1,216 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class WP_CustomMenu_Block_Navigation extends Mage_Catalog_Block_Navigation
|
4 |
+
{
|
5 |
+
const CUSTOM_BLOCK_TEMPLATE = 'wp_custom_menu_%d';
|
6 |
+
|
7 |
+
public function drawCustomMenuItem($category, $level = 0, $last = false)
|
8 |
+
{
|
9 |
+
if (!$category->getIsActive()) return '';
|
10 |
+
|
11 |
+
$html = array();
|
12 |
+
|
13 |
+
$id = $category->getId();
|
14 |
+
// --- Static Block ---
|
15 |
+
$blockId = sprintf('wp_custom_menu_%d', $id); // --- static block key
|
16 |
+
$blockHtml = $this->getLayout()->createBlock('cms/block')->setBlockId($blockId)->toHtml();
|
17 |
+
// --- Sub Categories ---
|
18 |
+
$activeChildren = $this->getActiveChildren($category, $level);
|
19 |
+
// --- class for active category ---
|
20 |
+
$active = ''; if ($this->isCategoryActive($category)) $active = ' act';
|
21 |
+
// --- Popup functions for show ---
|
22 |
+
$drawPopup = ($blockHtml || count($activeChildren));
|
23 |
+
if ($drawPopup)
|
24 |
+
{
|
25 |
+
$html[] = '<div id="menu' . $id . '" class="menu' . $active . '" onmouseover="wpShowMenuPopup(this, \'popup' . $id . '\');" onmouseout="wpHideMenuPopup(this, event, \'popup' . $id . '\', \'menu' . $id . '\')">';
|
26 |
+
}
|
27 |
+
else
|
28 |
+
{
|
29 |
+
$html[] = '<div id="menu' . $id . '" class="menu">';
|
30 |
+
}
|
31 |
+
// --- Top Menu Item ---
|
32 |
+
$html[] = '<div class="parentMenu">';
|
33 |
+
$html[] = '<a href="'.$this->getCategoryUrl($category).'">';
|
34 |
+
$name = $this->escapeHtml($category->getName());
|
35 |
+
$name = str_replace(' ', ' ', $name);
|
36 |
+
$html[] = '<span>' . $name . '</span>';
|
37 |
+
$html[] = '</a>';
|
38 |
+
$html[] = '</div>';
|
39 |
+
$html[] = '</div>';
|
40 |
+
// --- Add Popup block (hidden) ---
|
41 |
+
if ($drawPopup)
|
42 |
+
{
|
43 |
+
// --- Popup function for hide ---
|
44 |
+
$html[] = '<div id="popup' . $id . '" class="popup" onmouseout="wpHideMenuPopup(this, event, \'popup' . $id . '\', \'menu' . $id . '\')">';
|
45 |
+
// --- draw Sub Categories ---
|
46 |
+
if (count($activeChildren))
|
47 |
+
{
|
48 |
+
$html[] = '<div class="block1">';
|
49 |
+
$html[] = $this->drawColumns($activeChildren);
|
50 |
+
$html[] = '<div class="clearBoth"></div>';
|
51 |
+
$html[] = '</div>';
|
52 |
+
}
|
53 |
+
// --- draw Custom User Block ---
|
54 |
+
if ($blockHtml)
|
55 |
+
{
|
56 |
+
$html[] = '<div class="block2">';
|
57 |
+
$html[] = $blockHtml;
|
58 |
+
$html[] = '</div>';
|
59 |
+
}
|
60 |
+
$html[] = '</div>';
|
61 |
+
}
|
62 |
+
|
63 |
+
$html = implode("\n", $html);
|
64 |
+
return $html;
|
65 |
+
}
|
66 |
+
|
67 |
+
public function drawColumns($children)
|
68 |
+
{
|
69 |
+
$html = '';
|
70 |
+
// --- explode by columns ---
|
71 |
+
$columns = (int)Mage::getStoreConfig('custom_menu/columns/count');
|
72 |
+
if ($columns < 1) $columns = 1;
|
73 |
+
$chunks = $this->explodeByColumns($children, $columns);
|
74 |
+
// --- draw columns ---
|
75 |
+
foreach ($chunks as $key => $value)
|
76 |
+
{
|
77 |
+
if (!count($value)) continue;
|
78 |
+
$html.= '<div class="column">';
|
79 |
+
$html.= $this->drawMenuItem($value, 1);
|
80 |
+
$html.= '</div>';
|
81 |
+
}
|
82 |
+
return $html;
|
83 |
+
}
|
84 |
+
|
85 |
+
protected function getActiveChildren($parent, $level)
|
86 |
+
{
|
87 |
+
$activeChildren = array();
|
88 |
+
// --- check level ---
|
89 |
+
$maxLevel = (int)Mage::getStoreConfig('custom_menu/general/max_level');
|
90 |
+
if ($maxLevel > 0)
|
91 |
+
{
|
92 |
+
if ($level >= ($maxLevel - 1)) return $activeChildren;
|
93 |
+
}
|
94 |
+
// --- / check level ---
|
95 |
+
if (Mage::helper('catalog/category_flat')->isEnabled())
|
96 |
+
{
|
97 |
+
$children = $parent->getChildrenNodes();
|
98 |
+
$childrenCount = count($children);
|
99 |
+
}
|
100 |
+
else
|
101 |
+
{
|
102 |
+
$children = $parent->getChildren();
|
103 |
+
$childrenCount = $children->count();
|
104 |
+
}
|
105 |
+
$hasChildren = $children && $childrenCount;
|
106 |
+
if ($hasChildren)
|
107 |
+
{
|
108 |
+
foreach ($children as $child)
|
109 |
+
{
|
110 |
+
if ($child->getIsActive())
|
111 |
+
{
|
112 |
+
array_push($activeChildren, $child);
|
113 |
+
}
|
114 |
+
}
|
115 |
+
}
|
116 |
+
return $activeChildren;
|
117 |
+
}
|
118 |
+
|
119 |
+
private function explodeByColumns($target, $num)
|
120 |
+
{
|
121 |
+
$count = count($target);
|
122 |
+
if ($count) $target = array_chunk($target, ceil($count / $num));
|
123 |
+
$target = array_pad($target, $num, array());
|
124 |
+
#return $target;
|
125 |
+
if ((int)Mage::getStoreConfig('custom_menu/columns/integrate') && count($target))
|
126 |
+
{
|
127 |
+
// --- combine consistently numerically small column ---
|
128 |
+
$max = 0; $columnsLength = array();
|
129 |
+
foreach ($target as $key => $child)
|
130 |
+
{
|
131 |
+
$count = 0;
|
132 |
+
$this->_countChild($child, 1, $count);
|
133 |
+
if ($max < $count) $max = $count;
|
134 |
+
$columnsLength[$key] = $count;
|
135 |
+
}
|
136 |
+
$xColumns = array(); $column = array(); $cnt = 0;
|
137 |
+
$xColumnsLength = array(); $k = 0;
|
138 |
+
foreach ($columnsLength as $key => $count)
|
139 |
+
{
|
140 |
+
$cnt+= $count;
|
141 |
+
if ($cnt > $max && count($column))
|
142 |
+
{
|
143 |
+
$xColumns[$k] = $column;
|
144 |
+
$xColumnsLength[$k] = $cnt - $count;
|
145 |
+
$k++; $column = array(); $cnt = $count;
|
146 |
+
}
|
147 |
+
$column = array_merge($column, $target[$key]);
|
148 |
+
}
|
149 |
+
$xColumns[$k] = $column;
|
150 |
+
$xColumnsLength[$k] = $cnt - $count;
|
151 |
+
// --- integrate columns of one element ---
|
152 |
+
$target = $xColumns; $xColumns = array(); $nextKey = -1;
|
153 |
+
if ($max > 1 && count($target) > 1)
|
154 |
+
{
|
155 |
+
foreach($target as $key => $column)
|
156 |
+
{
|
157 |
+
if ($key == $nextKey) continue;
|
158 |
+
if ($xColumnsLength[$key] == 1)
|
159 |
+
{
|
160 |
+
$nextKey = $key+1;
|
161 |
+
if (isset($target[$nextKey]))
|
162 |
+
$xColumns[] = array_merge($column, $target[$nextKey]);
|
163 |
+
}
|
164 |
+
else
|
165 |
+
$xColumns[] = $column;
|
166 |
+
}
|
167 |
+
$target = $xColumns;
|
168 |
+
}
|
169 |
+
}
|
170 |
+
return $target;
|
171 |
+
}
|
172 |
+
|
173 |
+
private function _countChild($children, $level, &$count)
|
174 |
+
{
|
175 |
+
foreach ($children as $child)
|
176 |
+
{
|
177 |
+
if ($child->getIsActive())
|
178 |
+
{
|
179 |
+
$count++; $activeChildren = $this->getActiveChildren($child, $level);
|
180 |
+
if (count($activeChildren) > 0) $this->_countChild($activeChildren, $level + 1, $count);
|
181 |
+
}
|
182 |
+
}
|
183 |
+
}
|
184 |
+
|
185 |
+
public function drawMenuItem($children, $level = 1)
|
186 |
+
{
|
187 |
+
$html = '<div class="itemMenu level' . $level . '">';
|
188 |
+
$keyCurrent = $this->getCurrentCategory()->getId();
|
189 |
+
foreach ($children as $child)
|
190 |
+
{
|
191 |
+
if ($child->getIsActive())
|
192 |
+
{
|
193 |
+
// --- class for active category ---
|
194 |
+
$active = '';
|
195 |
+
if ($this->isCategoryActive($child))
|
196 |
+
{
|
197 |
+
$active = ' actParent';
|
198 |
+
if ($child->getId() == $keyCurrent) $active = ' act';
|
199 |
+
}
|
200 |
+
// --- format category name ---
|
201 |
+
$name = $this->escapeHtml($child->getName());
|
202 |
+
$name = str_replace(' ', ' ', $name);
|
203 |
+
$html.= '<a class="itemMenuName level' . $level . $active . '" href="' . $this->getCategoryUrl($child) . '"><span>' . $name . '</span></a>';
|
204 |
+
$activeChildren = $this->getActiveChildren($child, $level);
|
205 |
+
if (count($activeChildren) > 0)
|
206 |
+
{
|
207 |
+
$html.= '<div class="itemSubMenu level' . $level . '">';
|
208 |
+
$html.= $this->drawMenuItem($activeChildren, $level + 1);
|
209 |
+
$html.= '</div>';
|
210 |
+
}
|
211 |
+
}
|
212 |
+
}
|
213 |
+
$html.= '</div>';
|
214 |
+
return $html;
|
215 |
+
}
|
216 |
+
}
|
app/code/local/WP/CustomMenu/Helper/Data.php
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class WP_CustomMenu_Helper_Data extends Mage_Core_Helper_Abstract
|
4 |
+
{
|
5 |
+
|
6 |
+
}
|
app/code/local/WP/CustomMenu/etc/adminhtml.xml
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<config>
|
3 |
+
<acl>
|
4 |
+
<resources>
|
5 |
+
<admin>
|
6 |
+
<children>
|
7 |
+
<system>
|
8 |
+
<children>
|
9 |
+
<config>
|
10 |
+
<children>
|
11 |
+
<custom_menu translate="title" module="custommenu">
|
12 |
+
<title>Custom Menu</title>
|
13 |
+
<sort_order>300</sort_order>
|
14 |
+
</custom_menu>
|
15 |
+
</children>
|
16 |
+
</config>
|
17 |
+
</children>
|
18 |
+
</system>
|
19 |
+
</children>
|
20 |
+
</admin>
|
21 |
+
</resources>
|
22 |
+
</acl>
|
23 |
+
</config>
|
app/code/local/WP/CustomMenu/etc/config.xml
ADDED
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<WP_CustomMenu>
|
5 |
+
<version>1.2.5</version>
|
6 |
+
</WP_CustomMenu>
|
7 |
+
</modules>
|
8 |
+
<frontend>
|
9 |
+
<layout>
|
10 |
+
<updates>
|
11 |
+
<custommenu>
|
12 |
+
<file>custommenu.xml</file>
|
13 |
+
</custommenu>
|
14 |
+
</updates>
|
15 |
+
</layout>
|
16 |
+
</frontend>
|
17 |
+
<adminhtml>
|
18 |
+
<acl>
|
19 |
+
<resources>
|
20 |
+
<all>
|
21 |
+
<title>Allow Everything</title>
|
22 |
+
</all>
|
23 |
+
<admin>
|
24 |
+
<children>
|
25 |
+
<WP_CustomMenu>
|
26 |
+
<title>CustomMenu Module</title>
|
27 |
+
<sort_order>10</sort_order>
|
28 |
+
</WP_CustomMenu>
|
29 |
+
</children>
|
30 |
+
</admin>
|
31 |
+
</resources>
|
32 |
+
</acl>
|
33 |
+
</adminhtml>
|
34 |
+
<global>
|
35 |
+
<blocks>
|
36 |
+
<catalog>
|
37 |
+
<rewrite>
|
38 |
+
<navigation>WP_CustomMenu_Block_Navigation</navigation>
|
39 |
+
</rewrite>
|
40 |
+
</catalog>
|
41 |
+
</blocks>
|
42 |
+
<helpers>
|
43 |
+
<custommenu>
|
44 |
+
<class>WP_CustomMenu_Helper</class>
|
45 |
+
</custommenu>
|
46 |
+
</helpers>
|
47 |
+
</global>
|
48 |
+
<default>
|
49 |
+
<custom_menu>
|
50 |
+
<general>
|
51 |
+
<enabled>0</enabled>
|
52 |
+
<max_level>2</max_level>
|
53 |
+
</general>
|
54 |
+
<columns>
|
55 |
+
<count>3</count>
|
56 |
+
<integrate>1</integrate>
|
57 |
+
</columns>
|
58 |
+
<popup>
|
59 |
+
<width>0</width>
|
60 |
+
<top_offset>30</top_offset>
|
61 |
+
<right_offset_min>48</right_offset_min>
|
62 |
+
</popup>
|
63 |
+
</custom_menu>
|
64 |
+
</default>
|
65 |
+
</config>
|
app/code/local/WP/CustomMenu/etc/system.xml
ADDED
@@ -0,0 +1,117 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<tabs>
|
4 |
+
<web_and_people translate="label" module="custommenu">
|
5 |
+
<label>Web-And-People</label>
|
6 |
+
<sort_order>150</sort_order>
|
7 |
+
</web_and_people>
|
8 |
+
</tabs>
|
9 |
+
<sections>
|
10 |
+
<custom_menu translate="label" module="custommenu">
|
11 |
+
<label>Custom Menu</label>
|
12 |
+
<tab>web_and_people</tab>
|
13 |
+
<frontend_type>text</frontend_type>
|
14 |
+
<sort_order>100</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 |
+
<general translate="label">
|
20 |
+
<label>General</label>
|
21 |
+
<frontend_type>text</frontend_type>
|
22 |
+
<sort_order>10</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 |
+
<enabled translate="label comment">
|
28 |
+
<label>Enable</label>
|
29 |
+
<frontend_type>select</frontend_type>
|
30 |
+
<comment><![CDATA[In order to display a custom block in the popup, use the <b>Static Block</b> (<strong>CMS->Static Blocks</strong> section) with the ID like "<b>wp_custom_menu_XX</b>", where "<b>XX</b>" is the identifier of the linked category]]></comment>
|
31 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
32 |
+
<sort_order>1</sort_order>
|
33 |
+
<show_in_default>1</show_in_default>
|
34 |
+
<show_in_website>1</show_in_website>
|
35 |
+
<show_in_store>1</show_in_store>
|
36 |
+
</enabled>
|
37 |
+
<max_level translate="label comment">
|
38 |
+
<label>Visible menu depth</label>
|
39 |
+
<comment><![CDATA[e.g. 1, 2, 3, 4 (0 - disable limits). For example, if you set this value to <b>2</b>, only second level categories will be displayed.]]></comment>
|
40 |
+
<frontend_type>text</frontend_type>
|
41 |
+
<sort_order>3</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 |
+
</max_level>
|
46 |
+
</fields>
|
47 |
+
</general>
|
48 |
+
<columns translate="label">
|
49 |
+
<label>Columns</label>
|
50 |
+
<frontend_type>text</frontend_type>
|
51 |
+
<sort_order>15</sort_order>
|
52 |
+
<show_in_default>1</show_in_default>
|
53 |
+
<show_in_website>1</show_in_website>
|
54 |
+
<show_in_store>1</show_in_store>
|
55 |
+
<fields>
|
56 |
+
<count translate="label comment">
|
57 |
+
<label>Number of columns</label>
|
58 |
+
<comment>e.g. 1, 2, 3. The maximum number of columns in the popup.</comment>
|
59 |
+
<frontend_type>text</frontend_type>
|
60 |
+
<sort_order>1</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 |
+
</count>
|
65 |
+
<integrate translate="label comment">
|
66 |
+
<label>Merge small subcategories</label>
|
67 |
+
<frontend_type>select</frontend_type>
|
68 |
+
<comment><![CDATA[Merge small subcategory lists into one column (except the extream left categories).]]></comment>
|
69 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
70 |
+
<sort_order>3</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 |
+
</integrate>
|
75 |
+
</fields>
|
76 |
+
</columns>
|
77 |
+
<popup translate="label">
|
78 |
+
<label>Popup settings</label>
|
79 |
+
<frontend_type>text</frontend_type>
|
80 |
+
<sort_order>20</sort_order>
|
81 |
+
<show_in_default>1</show_in_default>
|
82 |
+
<show_in_website>1</show_in_website>
|
83 |
+
<show_in_store>1</show_in_store>
|
84 |
+
<fields>
|
85 |
+
<width translate="label comment">
|
86 |
+
<label>Width</label>
|
87 |
+
<comment>in pixels, (0 - no fixed width)</comment>
|
88 |
+
<frontend_type>text</frontend_type>
|
89 |
+
<sort_order>1</sort_order>
|
90 |
+
<show_in_default>1</show_in_default>
|
91 |
+
<show_in_website>1</show_in_website>
|
92 |
+
<show_in_store>1</show_in_store>
|
93 |
+
</width>
|
94 |
+
<top_offset translate="label comment">
|
95 |
+
<label>Top offset</label>
|
96 |
+
<comment>in pixels</comment>
|
97 |
+
<frontend_type>text</frontend_type>
|
98 |
+
<sort_order>3</sort_order>
|
99 |
+
<show_in_default>1</show_in_default>
|
100 |
+
<show_in_website>1</show_in_website>
|
101 |
+
<show_in_store>1</show_in_store>
|
102 |
+
</top_offset>
|
103 |
+
<right_offset_min translate="label comment">
|
104 |
+
<label>Right offset (minimum)</label>
|
105 |
+
<comment>in pixels</comment>
|
106 |
+
<frontend_type>text</frontend_type>
|
107 |
+
<sort_order>5</sort_order>
|
108 |
+
<show_in_default>1</show_in_default>
|
109 |
+
<show_in_website>1</show_in_website>
|
110 |
+
<show_in_store>1</show_in_store>
|
111 |
+
</right_offset_min>
|
112 |
+
</fields>
|
113 |
+
</popup>
|
114 |
+
</groups>
|
115 |
+
</custom_menu>
|
116 |
+
</sections>
|
117 |
+
</config>
|
app/design/frontend/base/default/layout/custommenu.xml
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<layout version="0.1.0">
|
3 |
+
<default>
|
4 |
+
<reference name="head">
|
5 |
+
<action method="addCss" ifconfig="custom_menu/general/enabled"><stylesheet>css/custommenu.css</stylesheet></action>
|
6 |
+
<action method="addItem" ifconfig="custom_menu/general/enabled"><type>skin_js</type><name>js/custommenu.js</name></action>
|
7 |
+
</reference>
|
8 |
+
<reference name="catalog.topnav">
|
9 |
+
<action method="setTemplate" ifconfig="custom_menu/general/enabled"><template>custommenu/top.phtml</template></action>
|
10 |
+
</reference>
|
11 |
+
</default>
|
12 |
+
</layout>
|
app/design/frontend/base/default/template/custommenu/top.phtml
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php $_categories = $this->getStoreCategories() ?>
|
2 |
+
<?php if(count($_categories)): ?>
|
3 |
+
<div class="nav-container">
|
4 |
+
<div id="custommenu">
|
5 |
+
<?php foreach ($_categories as $_category): ?>
|
6 |
+
<?php echo $this->drawCustomMenuItem($_category) ?>
|
7 |
+
<?php endforeach ?>
|
8 |
+
<div class="clearBoth"></div>
|
9 |
+
</div>
|
10 |
+
</div>
|
11 |
+
<script type="text/javascript">
|
12 |
+
//<![CDATA[
|
13 |
+
var CUSTOMMENU_POPUP_WIDTH = <?php echo (int)Mage::getStoreConfig('custom_menu/popup/width')?>;
|
14 |
+
var CUSTOMMENU_POPUP_TOP_OFFSET = <?php echo (int)Mage::getStoreConfig('custom_menu/popup/top_offset')?>;
|
15 |
+
var CUSTOMMENU_POPUP_RIGHT_OFFSET_MIN = <?php echo (int)Mage::getStoreConfig('custom_menu/popup/right_offset_min')?>;
|
16 |
+
//]]>
|
17 |
+
</script>
|
18 |
+
<?php endif ?>
|
app/etc/modules/WP_CustomMenu.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<WP_CustomMenu>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>local</codePool>
|
7 |
+
</WP_CustomMenu>
|
8 |
+
</modules>
|
9 |
+
</config>
|
package.xml
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>wp_custom_menu</name>
|
4 |
+
<version>1.2.5</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license uri="http://www.opensource.org/licenses/academic.php">Academic Free License (AFL)</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>Custom Navigation Menu (WebAndPeople.com) for magento v1.4</summary>
|
10 |
+
<description>Custom Navigation Menu (WebAndPeople.com) for magento v1.4</description>
|
11 |
+
<notes>+ integrate small columns</notes>
|
12 |
+
<authors><author><name>WebAndPeople</name><user>auto-converted</user><email>design@webandpeople.com</email></author><author><name>y.gerassimenko</name><user>auto-converted</user><email>y.gerassimenko@webandpeople.com</email></author></authors>
|
13 |
+
<date>2011-02-08</date>
|
14 |
+
<time>12:28:13</time>
|
15 |
+
<contents><target name="mageweb"><dir name="app"><dir name="code"><dir name="local"><dir name="WP"><dir name="CustomMenu"><dir name="Block"><file name="Navigation.php" hash="26960c10ecec6d519de78562fce6b063"/></dir><dir name="Helper"><file name="Data.php" hash="34835545685bf29a95e03f914cf69bcb"/></dir><dir name="etc"><file name="adminhtml.xml" hash="8aa1dd048cfde0f8417d91261e6eda3b"/><file name="config.xml" hash="908efb7a583196bee37619fccc6a741c"/><file name="system.xml" hash="f87fca51db2d2062c9db2228d333d0ee"/></dir></dir></dir></dir></dir><dir name="design"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="custommenu.xml" hash="ed16b9066c2e5e2235ec09cb2e6988ae"/></dir><dir name="template"><dir name="custommenu"><file name="top.phtml" hash="2cd4cb77875488a96afa4e03860737e9"/></dir></dir></dir></dir></dir></dir><dir name="etc"><dir name="modules"><file name="WP_CustomMenu.xml" hash="cfe1d1974c20f4ac9f2d5ace4916c5ab"/></dir></dir></dir><dir name="skin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="css"><file name="custommenu.css" hash="4bc0464f899a84e57cd9435ed35f58a7"/></dir><dir name="js"><file name="custommenu.js" hash="c3b3468a1f6f9b0579ebf7cabaa8bb80"/></dir></dir></dir></dir></dir></target></contents>
|
16 |
+
<compatible/>
|
17 |
+
<dependencies/>
|
18 |
+
</package>
|
skin/frontend/base/default/css/custommenu.css
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#custommenu {
|
2 |
+
position:relative;
|
3 |
+
z-index:1000;
|
4 |
+
font-size: 14px;
|
5 |
+
margin: 0 auto;
|
6 |
+
padding: 0 16px;
|
7 |
+
width: 918px;
|
8 |
+
}
|
9 |
+
div.menu {
|
10 |
+
float: left;
|
11 |
+
}
|
12 |
+
div.menu.act {
|
13 |
+
background-color:#ADD8E6;
|
14 |
+
}
|
15 |
+
div.menu.active {
|
16 |
+
background-color:#FFC0CB;
|
17 |
+
}
|
18 |
+
div.popup {
|
19 |
+
position:absolute;
|
20 |
+
z-index:3000;
|
21 |
+
border:5px solid #FFC0CB;
|
22 |
+
display: none;
|
23 |
+
background-color:#fff;
|
24 |
+
text-align:left;
|
25 |
+
}
|
26 |
+
div.menu, div.popup {
|
27 |
+
padding: 5px 12px 6px 8px;
|
28 |
+
}
|
29 |
+
div.menu a, div.popup a {
|
30 |
+
text-decoration: none;
|
31 |
+
display:block;
|
32 |
+
}
|
33 |
+
div.popup a.actParent {
|
34 |
+
color: #4D4D4D;
|
35 |
+
}
|
36 |
+
div.popup a.act {
|
37 |
+
color: #A52A2A;
|
38 |
+
}
|
39 |
+
div.column {
|
40 |
+
float:left;
|
41 |
+
width:200px; /* column width */
|
42 |
+
padding:5px;
|
43 |
+
}
|
44 |
+
div.itemSubMenu {
|
45 |
+
margin-left:20px;
|
46 |
+
}
|
47 |
+
.clearBoth {
|
48 |
+
clear:both;
|
49 |
+
}
|
skin/frontend/base/default/js/custommenu.js
ADDED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
function wpShowMenuPopup(objMenu, popupId)
|
2 |
+
{
|
3 |
+
objMenu = $(objMenu.id); var popup = $(popupId); if (!popup) return;
|
4 |
+
popup.style.display = 'block';
|
5 |
+
objMenu.addClassName('active');
|
6 |
+
var popupWidth = CUSTOMMENU_POPUP_WIDTH;
|
7 |
+
if (!popupWidth) popupWidth = popup.getWidth();
|
8 |
+
var pos = wpPopupPos(objMenu, popupWidth);
|
9 |
+
popup.style.top = pos.top + 'px';
|
10 |
+
popup.style.left = pos.left + 'px';
|
11 |
+
if (CUSTOMMENU_POPUP_WIDTH) popup.style.width = CUSTOMMENU_POPUP_WIDTH + 'px';
|
12 |
+
}
|
13 |
+
|
14 |
+
function wpPopupPos(objMenu, w)
|
15 |
+
{
|
16 |
+
var pos = objMenu.cumulativeOffset();
|
17 |
+
var wraper = $('custommenu');
|
18 |
+
var posWraper = wraper.cumulativeOffset();
|
19 |
+
var wWraper = wraper.getWidth() - CUSTOMMENU_POPUP_RIGHT_OFFSET_MIN;
|
20 |
+
var xTop = pos.top - posWraper.top + CUSTOMMENU_POPUP_TOP_OFFSET;
|
21 |
+
var xLeft = pos.left - posWraper.left;
|
22 |
+
if ((xLeft + w) > wWraper) xLeft = wWraper - w;
|
23 |
+
return {'top': xTop, 'left': xLeft};
|
24 |
+
}
|
25 |
+
|
26 |
+
function wpHideMenuPopup(element, event, popupId, menuId)
|
27 |
+
{
|
28 |
+
element = $(element.id); var popup = $(popupId); if (!popup) return;
|
29 |
+
var current_mouse_target = null;
|
30 |
+
if (event.toElement)
|
31 |
+
{
|
32 |
+
current_mouse_target = event.toElement;
|
33 |
+
}
|
34 |
+
else if (event.relatedTarget)
|
35 |
+
{
|
36 |
+
current_mouse_target = event.relatedTarget;
|
37 |
+
}
|
38 |
+
if (!wpIsChildOf(element, current_mouse_target) && element != current_mouse_target)
|
39 |
+
{
|
40 |
+
if (!wpIsChildOf(popup, current_mouse_target) && popup != current_mouse_target)
|
41 |
+
{
|
42 |
+
popup.style.display = 'none';
|
43 |
+
$(menuId).removeClassName('active');
|
44 |
+
}
|
45 |
+
}
|
46 |
+
}
|
47 |
+
|
48 |
+
function wpIsChildOf(parent, child)
|
49 |
+
{
|
50 |
+
if (child != null)
|
51 |
+
{
|
52 |
+
while (child.parentNode)
|
53 |
+
{
|
54 |
+
if ((child = child.parentNode) == parent)
|
55 |
+
{
|
56 |
+
return true;
|
57 |
+
}
|
58 |
+
}
|
59 |
+
}
|
60 |
+
return false;
|
61 |
+
}
|