RicoNeitzel_VertNav - Version 0.3.0

Version Notes

Add a vertical menu to your site. Features many css classes and several configuration options.

Download this release

Release Info

Developer Magento Core Team
Extension RicoNeitzel_VertNav
Version 0.3.0
Comparing to
See all releases


Code changes from version 0.2.8 to 0.3.0

app/code/community/RicoNeitzel/VertNav/Block/Navigation.php CHANGED
@@ -136,14 +136,15 @@ class RicoNeitzel_VertNav_Block_Navigation extends Mage_Catalog_Block_Navigation
136
$levelClass[] = implode('-', $combineClasses);
137
138
$levelClass = array_merge($levelClass, $combineClasses);
139
-
140
- $levelClass[] = $this->_getClassNameFromCategoryName($category);
141
-
142
- $productCount = '';
143
- if (Mage::getStoreConfig('catalog/vertnav/display_product_count'))
144
- {
145
- $productCount = '<span class="product-count"> (' . $this->_getProductCount($category) . ')</span>';
146
- }
147
148
// indent HTML!
149
$html[1] = str_pad ( "", (($level * 2 ) + 4), " " ).'<span class="vertnav-cat"><a href="'.$this->getCategoryUrl($category).'"><span>'.$this->htmlEscape($category->getName()).'</span></a>'.$productCount."</span>\n";
@@ -156,14 +157,14 @@ class RicoNeitzel_VertNav_Block_Navigation extends Mage_Catalog_Block_Navigation
156
|| ($autoExpand && $autoMaxDepth > $level+1)
157
)
158
{
159
- if ($category instanceof Mage_Catalog_Model_Category)
160
- {
161
- $children = $this->toLinearArray($category->getChildrenCategories());
162
- }
163
- else
164
- {
165
- $children = $category->getChildren();
166
- }
167
168
$hasChildren = $children && ($childrenCount = count($children));
169
if ($hasChildren)
@@ -224,6 +225,11 @@ class RicoNeitzel_VertNav_Block_Navigation extends Mage_Catalog_Block_Navigation
224
return $array;
225
}
226
227
protected function _getClassNameFromCategoryName($category)
228
{
229
$name = $category->getName();
@@ -254,14 +260,17 @@ class RicoNeitzel_VertNav_Block_Navigation extends Mage_Catalog_Block_Navigation
254
255
protected function _getProductCount($category)
256
{
257
- $count = 0;
258
- if ($category instanceof Mage_Catalog_Model_Category)
259
{
260
- $count = $category->getProductCount();
261
- }
262
- elseif ($category instanceof Varien_Data_Tree_Node)
263
- {
264
- $count = $this->_getProductCountFromTreeNode($category);
265
}
266
return $count;
267
}
@@ -338,8 +347,46 @@ class RicoNeitzel_VertNav_Block_Navigation extends Mage_Catalog_Block_Navigation
338
->addFieldToFilter('parent_id', $parent)
339
->addAttributeToSort('position', 'ASC')
340
;
341
342
$this->_storeCategories = $storeCategories;
343
return $storeCategories;
344
}
345
}
136
$levelClass[] = implode('-', $combineClasses);
137
138
$levelClass = array_merge($levelClass, $combineClasses);
139
+
140
+ $levelClass[] = $this->_getClassNameFromCategoryName($category);
141
+
142
+ $productCount = '';
143
+ if ($this->displayProductCount())
144
+ {
145
+ $n = $this->_getProductCount($category);
146
+ $productCount = '<span class="product-count"> (' . $n . ')</span>';
147
+ }
148
149
// indent HTML!
150
$html[1] = str_pad ( "", (($level * 2 ) + 4), " " ).'<span class="vertnav-cat"><a href="'.$this->getCategoryUrl($category).'"><span>'.$this->htmlEscape($category->getName()).'</span></a>'.$productCount."</span>\n";
157
|| ($autoExpand && $autoMaxDepth > $level+1)
158
)
159
{
160
+ $children = $category->getChildrenCategories();
161
+ if ($this->displayProductCount())
162
+ {
163
+ $this->_addProductCount($children);
164
+ }
165
+ $children = $this->toLinearArray($children);
166
+
167
+ //usort($children, array($this, '_sortCategoryArrayByName'));
168
169
$hasChildren = $children && ($childrenCount = count($children));
170
if ($hasChildren)
225
return $array;
226
}
227
228
+ protected function _sortCategoryArrayByName($a, $b)
229
+ {
230
+ return strcoll($a->getName(), $b->getName());
231
+ }
232
+
233
protected function _getClassNameFromCategoryName($category)
234
{
235
$name = $category->getName();
260
261
protected function _getProductCount($category)
262
{
263
+ if (null === ($count = $category->getData('product_count')))
264
{
265
+ $count = 0;
266
+ if ($category instanceof Mage_Catalog_Model_Category)
267
+ {
268
+ $count = $category->getProductCount();
269
+ }
270
+ elseif ($category instanceof Varien_Data_Tree_Node)
271
+ {
272
+ $count = $this->_getProductCountFromTreeNode($category);
273
+ }
274
}
275
return $count;
276
}
347
->addFieldToFilter('parent_id', $parent)
348
->addAttributeToSort('position', 'ASC')
349
;
350
+ if ($this->displayProductCount())
351
+ {
352
+ $this->_addProductCount($storeCategories);
353
+ }
354
355
$this->_storeCategories = $storeCategories;
356
return $storeCategories;
357
}
358
+
359
+ protected function _addProductCount($collection)
360
+ {
361
+ if ($collection instanceof Mage_Catalog_Model_Resource_Eav_Mysql4_Category_Collection)
362
+ {
363
+ if ($collection->isLoaded())
364
+ {
365
+ $collection->loadProductCount($collection->getItems());
366
+ }
367
+ else
368
+ {
369
+ $collection->setLoadProductCount(true);
370
+ }
371
+ }
372
+ else
373
+ {
374
+ $this->_getProductCollectionResource()->addCountToCategories($collection);
375
+ }
376
+ return $this;
377
+ }
378
+
379
+ protected function _getProductCollectionResource()
380
+ {
381
+ if (null === $this->_productCollection)
382
+ {
383
+ $this->_productCollection = Mage::getResourceModel('catalog/product_collection');
384
+ }
385
+ return $this->_productCollection;
386
+ }
387
+
388
+ public function displayProductCount()
389
+ {
390
+ return Mage::getStoreConfigFlag('catalog/vertnav/display_product_count');
391
+ }
392
}
app/code/community/RicoNeitzel/VertNav/etc/config.xml CHANGED
@@ -2,7 +2,7 @@
2
<config>
3
<modules>
4
<RicoNeitzel_VertNav>
5
- <version>0.2.8</version>
6
</RicoNeitzel_VertNav>
7
</modules>
8
2
<config>
3
<modules>
4
<RicoNeitzel_VertNav>
5
+ <version>0.3.0</version>
6
</RicoNeitzel_VertNav>
7
</modules>
8
app/design/frontend/base/default/layout/vertnav.xml ADDED
@@ -0,0 +1,59 @@
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Academic Free License (AFL 3.0)
9
+ * that is bundled with this package in the file LICENSE_AFL.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/afl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * DISCLAIMER
17
+ *
18
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
19
+ * versions in the future. If you wish to customize Magento for your
20
+ * needs please refer to http://www.magentocommerce.com for more information.
21
+ *
22
+ * @category design_default
23
+ * @package RickNeitzel
24
+ * @copyright Copyright (c) 2009 Vinai Kopp http//netzarbeiter.com/
25
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
26
+ */
27
+
28
+ -->
29
+ <layout version="0.1.0">
30
+ <default>
31
+ <reference name="head">
32
+ <action method="addItem"><type>skin_css</type><name>css/vertnav.css</name></action>
33
+ </reference>
34
+ <reference name="top.menu">
35
+ <action method="unsetChild" ifconfig="catalog/vertnav/hide_top"><name>catalog.topnav</name></action>
36
+ </reference>
37
+ <reference name="left">
38
+ <block type="vertnav/navigation" name="catalog.vertnav" template="vertnav/left.phtml" before="-" />
39
+ </reference>
40
+ </default>
41
+
42
+ <customer_account>
43
+ <reference name="left">
44
+ <action method="unsetChild"><name>catalog.vertnav</name></action>
45
+ </reference>
46
+ </customer_account>
47
+
48
+ <catalog_category_default>
49
+ <reference name="left">
50
+ <action method="unsetChild"><name>catalog.leftnav</name></action>
51
+ </reference>
52
+ </catalog_category_default>
53
+
54
+ <catalog_category_layered>
55
+ <reference name="catalog.leftnav">
56
+ <action method="unsetChild"><name>category_filter</name></action>
57
+ </reference>
58
+ </catalog_category_layered>
59
+ </layout>
app/design/frontend/base/default/template/vertnav/left.phtml ADDED
@@ -0,0 +1,56 @@
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-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 design_default
22
+ * @package RicoNeitzel
23
+ * @copyright Copyright (c) 2009 Vinai Kopp http//netzarbeiter.com/
24
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ /**
29
+ * Left menu for store
30
+ *
31
+ * @see RicoNeitzel_VertNav_Block_Navgation
32
+ * @see Mage_Catalog_Block_Navigation
33
+ */
34
+ ?>
35
+ <div class="vertnav-container">
36
+ <div class="">
37
+ <h4 class="no-display"><?php echo $this->__('Category Navigation:') ?></h4>
38
+ <ul id="vertnav">
39
+ <?php $store_categories = $this->toLinearArray($this->getStoreCategories()) ?>
40
+ <?php $count = count($store_categories) ?>
41
+ <?php foreach ($store_categories as $i => $_category): ?>
42
+ <?php $class = array() ?>
43
+ <?php if ($count == 1): ?>
44
+ <?php $class[] = 'only' ?>
45
+ <?php elseif (! $i): ?>
46
+ <?php $class[] = 'first' ?>
47
+ <?php elseif ($i == $count-1): ?>
48
+ <?php $class[] = 'last' ?>
49
+ <?php endif; ?>
50
+ <?php if (isset($store_categories[$i+1]) && $this->isCategoryActive($store_categories[$i+1])) $class[] = 'prev'; ?>
51
+ <?php if (isset($store_categories[$i-1]) && $this->isCategoryActive($store_categories[$i-1])) $class[] = 'next'; ?>
52
+ <?php echo $this->drawOpenCategoryItem($_category, 0, $class) ?>
53
+ <?php endforeach ?>
54
+ </ul>
55
+ </div>
56
+ </div>
app/design/frontend/default/default/template/vertnav/left.phtml CHANGED
@@ -32,7 +32,6 @@
32
* @see Mage_Catalog_Block_Navigation
33
*/
34
?>
35
-
36
<div class="vertnav-container">
37
<div class="">
38
<h4 class="no-display"><?php echo $this->__('Category Navigation:') ?></h4>
32
* @see Mage_Catalog_Block_Navigation
33
*/
34
?>
35
<div class="vertnav-container">
36
<div class="">
37
<h4 class="no-display"><?php echo $this->__('Category Navigation:') ?></h4>
app/locale/de_DE/RicoNeitzel_VertNav.csv CHANGED
@@ -9,5 +9,4 @@
9
"Same level as current category","Gleiche Ebene wie aktuelle Kategorie"
10
"Fallback to store base","Auf Store Basis zurückfallen"
11
"If no current category is selected","Wenn keine aktuelle Kategorie ausgewählt ist"
12
- "Category Level %d","Kategorie Ebene %d"
13
-
9
"Same level as current category","Gleiche Ebene wie aktuelle Kategorie"
10
"Fallback to store base","Auf Store Basis zurückfallen"
11
"If no current category is selected","Wenn keine aktuelle Kategorie ausgewählt ist"
12
+ "Category Level %d","Kategorie Ebene %d"
app/locale/es_MX/RicoNeitzel_VertNav.csv ADDED
@@ -0,0 +1,14 @@
1
+ "Display Product Count","Mostrar Conteo de Producto"
2
+ "Expand all categories","Expandir todas las categorias"
3
+ "Expand all max depth","Expandir todo a la profundidad máxima"
4
+ "Leave empty or set to 0 for no limit","Dejar vacío o poner en 0 para ilimitado"
5
+ "Hide Top Navigation","Ocultar Menu Horizontal"
6
+ "Root Categories","Categorias Raices"
7
+ "Store base","Tienda base"
8
+ "Current category children","Categoria hija actual"
9
+ "Same level as current category","Mismo nivel como en la categoria actual"
10
+ "Fallback to store base","Recurrir a la tienda base"
11
+ "If no current category is selected","Si niguna categoria actual es seleccionada"
12
+ "Category Level %d","Nivel de Categoria %d"
13
+ "Category Vertical Navigation","Navegación Vertical de Categorias"
14
+
package.xml CHANGED
@@ -1,7 +1,7 @@
1
<?xml version="1.0"?>
2
<package>
3
<name>RicoNeitzel_VertNav</name>
4
- <version>0.2.8</version>
5
<stability>stable</stability>
6
<license uri="http://opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
<channel>community</channel>
@@ -10,9 +10,9 @@
10
<description>Lots of css selectors available.</description>
11
<notes>Add a vertical menu to your site. Features many css classes and several configuration options.</notes>
12
<authors><author><name>Vinai Kopp</name><user>auto-converted</user><email>vinai@netzarbeiter.com</email></author></authors>
13
- <date>2009-10-04</date>
14
- <time>11:17:31</time>
15
- <contents><target name="magelocale"><dir name="de_DE"><file name="RicoNeitzel_VertNav.csv" hash="15cc5ae7507240ed6effab17b07d8de9"/></dir></target><target name="mageskin"><dir name="frontend"><dir name="default"><dir name="default"><dir name="css"><file name="vertnav.css" hash="48ed54348eefcc8e1e0286feb84cbe4e"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><file name="vertnav.xml" hash="956ada78dc7cd460a2e94a718e33dfa9"/></dir><dir name="template"><dir name="vertnav"><file name="left.phtml" hash="eeedbcdc4c757152ff888dfd9826f696"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="RicoNeitzel_VertNav.xml" hash="227d7980c24ebd629e1c1d4f10b8c62c"/></dir></target><target name="magecommunity"><dir name="RicoNeitzel"><dir name="VertNav"><dir name="Block"><file name="Navigation.php" hash="86514aad8b4bfc067b31a20831d7b8d0"/></dir><dir name="etc"><file name="config.xml" hash="33827f3e4c91803b7dff999c4653bee7"/><file name="system.xml" hash="cc8fc5c78f35883252d1cebb67e6b807"/></dir><dir name="Helper"><file name="Data.php" hash="8e340ac22d50a4ac719477a16a16a3e1"/></dir><dir name="Model"><dir name="System"><dir name="Config"><dir name="Source"><file name="Root.php" hash="2726c3c36c68fb603b30cc930f13cbca"/></dir></dir></dir></dir></dir></dir></target></contents>
16
<compatible/>
17
<dependencies/>
18
</package>
1
<?xml version="1.0"?>
2
<package>
3
<name>RicoNeitzel_VertNav</name>
4
+ <version>0.3.0</version>
5
<stability>stable</stability>
6
<license uri="http://opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
<channel>community</channel>
10
<description>Lots of css selectors available.</description>
11
<notes>Add a vertical menu to your site. Features many css classes and several configuration options.</notes>
12
<authors><author><name>Vinai Kopp</name><user>auto-converted</user><email>vinai@netzarbeiter.com</email></author></authors>
13
+ <date>2010-10-07</date>
14
+ <time>04:56:57</time>
15
+ <contents><target name="magelocale"><dir name="de_DE"><file name="RicoNeitzel_VertNav.csv" hash="d42b529ba0390d03812d979fbe498d49"/></dir><dir name="es_MX"><file name="RicoNeitzel_VertNav.csv" hash="54b83643165bc5b72ca8ce2122fd5422"/></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="css"><file name="vertnav.css" hash="48ed54348eefcc8e1e0286feb84cbe4e"/></dir></dir></dir><dir name="default"><dir name="default"><dir name="css"><file name="vertnav.css" hash="48ed54348eefcc8e1e0286feb84cbe4e"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="vertnav.xml" hash="956ada78dc7cd460a2e94a718e33dfa9"/></dir><dir name="template"><dir name="vertnav"><file name="left.phtml" hash="61fefa66d703ef6665400504231e58ea"/></dir></dir></dir></dir><dir name="default"><dir name="default"><dir name="layout"><file name="vertnav.xml" hash="956ada78dc7cd460a2e94a718e33dfa9"/></dir><dir name="template"><dir name="vertnav"><file name="left.phtml" hash="61fefa66d703ef6665400504231e58ea"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="RicoNeitzel_VertNav.xml" hash="227d7980c24ebd629e1c1d4f10b8c62c"/></dir></target><target name="magecommunity"><dir name="RicoNeitzel"><dir name="VertNav"><dir name="Block"><file name="Navigation.php" hash="caed5855057bc6b309b59989c35dcd14"/></dir><dir name="etc"><file name="config.xml" hash="898788e4199579083a37579806e3288c"/><file name="system.xml" hash="cc8fc5c78f35883252d1cebb67e6b807"/></dir><dir name="Helper"><file name="Data.php" hash="8e340ac22d50a4ac719477a16a16a3e1"/></dir><dir name="Model"><dir name="System"><dir name="Config"><dir name="Source"><file name="Root.php" hash="2726c3c36c68fb603b30cc930f13cbca"/></dir></dir></dir></dir></dir></dir></target></contents>
16
<compatible/>
17
<dependencies/>
18
</package>
skin/frontend/base/default/css/vertnav.css ADDED
@@ -0,0 +1,66 @@
1
+ .vertnav-container {
2
+ margin-top:10px;
3
+ }
4
+
5
+ #vertnav li .vertnav-cat {
6
+ display:block;
7
+ border-bottom:1px dotted gray;
8
+ padding:3px;
9
+ width:189px;
10
+ }
11
+
12
+ #vertnav li a {
13
+ }
14
+
15
+ #vertnav .inactive .vertnav-cat {
16
+ background-color:#C0C0C0;
17
+ }
18
+
19
+ #vertnav .next .vertnav-cat {
20
+ background-color:#DEDEDE;
21
+ }
22
+
23
+ #vertnav .prev .vertnav-cat {
24
+ background-color:#DEDEDE;
25
+ }
26
+
27
+ #vertnav .first .vertnav-cat {
28
+ }
29
+
30
+ #vertnav .last .vertnav-cat {
31
+ }
32
+
33
+ #vertnav .only .vertnav-cat {
34
+ }
35
+
36
+ #vertnav li.parent .vertnav-cat {
37
+ background-color:#E0E0E0;
38
+ font-weight:bold;
39
+ }
40
+
41
+ #vertnav li.active .vertnav-cat {
42
+ background-color:#FFFFFF;
43
+ font-weight:bold;
44
+ }
45
+
46
+ #vertnav li.inactive .vertnav-cat {
47
+ font-weight:normal;
48
+ }
49
+
50
+ #vertnav .level0 .vertnav-cat {
51
+ }
52
+
53
+ #vertnav .level1 .vertnav-cat {
54
+ padding-left:10px;
55
+ width:182px;
56
+ }
57
+
58
+ #vertnav .level2 .vertnav-cat {
59
+ padding-left:20px;
60
+ width:172px;
61
+ }
62
+
63
+ #vertnav .level3 .vertnav-cat {
64
+ padding-left:30px;
65
+ width:162px;
66
+ }