RicoNeitzel_VertNav - Version 0.2.7

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.2.7
Comparing to
See all releases


Code changes from version 0.2.3 to 0.2.7

app/code/community/RicoNeitzel/VertNav/Block/Navigation.php CHANGED
@@ -34,6 +34,7 @@
34
*/
35
class RicoNeitzel_VertNav_Block_Navigation extends Mage_Catalog_Block_Navigation
36
{
37
38
/**
39
* Add the customer group to the cache key so this module is compatible with more extensions.
@@ -114,10 +115,10 @@ class RicoNeitzel_VertNav_Block_Navigation extends Mage_Catalog_Block_Navigation
114
{
115
$html = array();
116
117
- //if (! $category instanceof Varien_Data_Tree_Node) return $html;
118
119
if ($this->_checkLoginCatalog()) return '';
120
-
121
if (! $category->getIsActive()) return '';
122
123
if (! isset($levelClass)) $levelClass = array();
@@ -152,12 +153,12 @@ class RicoNeitzel_VertNav_Block_Navigation extends Mage_Catalog_Block_Navigation
152
153
if (in_array($category->getId(), $this->getCurrentCategoryPath())
154
|| ($autoExpand && $autoMaxDepth == 0)
155
- || ($autoExpand && $autoMaxDepth > $level)
156
)
157
{
158
if ($category instanceof Mage_Catalog_Model_Category)
159
{
160
- $children = $category->getChildrenCategories();
161
}
162
else
163
{
@@ -167,7 +168,7 @@ class RicoNeitzel_VertNav_Block_Navigation extends Mage_Catalog_Block_Navigation
167
$hasChildren = $children && ($childrenCount = count($children));
168
if ($hasChildren)
169
{
170
- //$children = $this->toLinearArray($children);
171
$htmlChildren = '';
172
173
foreach ($children as $i => $child)
@@ -269,4 +270,76 @@ class RicoNeitzel_VertNav_Block_Navigation extends Mage_Catalog_Block_Navigation
269
{
270
return Mage::getModel('catalog/category')->setId($category->getId())->getProductCount();
271
}
272
}
34
*/
35
class RicoNeitzel_VertNav_Block_Navigation extends Mage_Catalog_Block_Navigation
36
{
37
+ protected $_storeCategories;
38
39
/**
40
* Add the customer group to the cache key so this module is compatible with more extensions.
115
{
116
$html = array();
117
118
+ //if (! $category instanceof Varien_Data_Tree_Node) return '';
119
120
if ($this->_checkLoginCatalog()) return '';
121
+
122
if (! $category->getIsActive()) return '';
123
124
if (! isset($levelClass)) $levelClass = array();
153
154
if (in_array($category->getId(), $this->getCurrentCategoryPath())
155
|| ($autoExpand && $autoMaxDepth == 0)
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
{
168
$hasChildren = $children && ($childrenCount = count($children));
169
if ($hasChildren)
170
{
171
+ $children = $this->toLinearArray($children);
172
$htmlChildren = '';
173
174
foreach ($children as $i => $child)
270
{
271
return Mage::getModel('catalog/category')->setId($category->getId())->getProductCount();
272
}
273
+
274
+ /**
275
+ * Get catagories of current store, using the max depth setting for the vertical navigation
276
+ *
277
+ * @return Varien_Data_Tree_Node_Collection
278
+ */
279
+ public function getStoreCategories()
280
+ {
281
+ if (isset($this->_storeCategories))
282
+ {
283
+ return $this->_storeCategories;
284
+ }
285
+
286
+ /* @var $category Mage_Catalog_Model_Category */
287
+ $category = Mage::getModel('catalog/category');
288
+
289
+ $parent = false;
290
+ switch (Mage::getStoreConfig('catalog/vertnav/vertnav_root'))
291
+ {
292
+ case 'current':
293
+ if (Mage::registry('current_category'))
294
+ {
295
+ $parent = Mage::registry('current_category')->getId();
296
+ }
297
+ break;
298
+ case 'siblings':
299
+ if (Mage::registry('current_category'))
300
+ {
301
+ $parent = Mage::registry('current_category')->getParentId();
302
+ }
303
+ break;
304
+ case 'root':
305
+ $parent = Mage::app()->getStore()->getRootCategoryId();
306
+ break;
307
+ default:
308
+ /*
309
+ * Display from level N
310
+ */
311
+ $fromLevel = Mage::getStoreConfig('catalog/vertnav/vertnav_root');
312
+ if (Mage::registry('current_category') && Mage::registry('current_category')->getLevel() >= $fromLevel)
313
+ {
314
+ $cat = Mage::registry('current_category');
315
+ while ($cat->getLevel() > $fromLevel)
316
+ {
317
+ $cat = $cat->getParentCategory();
318
+ }
319
+ $parent = $cat->getId();
320
+ }
321
+ }
322
+ if (! $parent && Mage::getStoreConfig('catalog/vertnav/fallback_to_root'))
323
+ {
324
+ $parent = Mage::app()->getStore()->getRootCategoryId();
325
+ }
326
+
327
+ /**
328
+ * Check if parent node of the store still exists
329
+ */
330
+ if (! $parent || ! $category->checkId($parent))
331
+ {
332
+ return array();
333
+ }
334
+
335
+ $storeCategories = $category->getCollection()
336
+ ->addIsActiveFilter()
337
+ ->addAttributeToSelect('name')
338
+ ->addFieldToFilter('parent_id', $parent)
339
+ ->addAttributeToSort('position', 'ASC')
340
+ ;
341
+
342
+ $this->_storeCategories = $storeCategories;
343
+ return $storeCategories;
344
+ }
345
}
app/code/community/RicoNeitzel/VertNav/Model/System/Config/Source/Root.php ADDED
@@ -0,0 +1,46 @@
1
+ <?php
2
+
3
+ class RicoNeitzel_VertNav_Model_System_Config_Source_Root
4
+ extends Mage_Eav_Model_Entity_Attribute_Source_Abstract
5
+ {
6
+ protected $_options;
7
+
8
+ public function toOptionArray()
9
+ {
10
+ if (! isset($this->_options))
11
+ {
12
+ $options = array(
13
+ array(
14
+ 'label' => Mage::helper('vertnav')->__('Store base'),
15
+ 'value' => 'root',
16
+ ),
17
+ array(
18
+ 'label' => Mage::helper('vertnav')->__('Current category children'),
19
+ 'value' => 'current',
20
+ ),
21
+ array(
22
+ 'label' => Mage::helper('vertnav')->__('Same level as current category'),
23
+ 'value' => 'siblings',
24
+ ),
25
+ );
26
+ $resource = Mage::getModel('catalog/category')->getResource();
27
+ $select = $resource->getReadConnection()->select()->reset()
28
+ ->from($resource->getTable('catalog/category'), new Zend_Db_Expr('MAX(`level`)'));
29
+ $maxDepth = $resource->getReadConnection()->fetchOne($select);
30
+ for ($i = 2; $i < $maxDepth; $i++)
31
+ {
32
+ $options[] = array(
33
+ 'label' => Mage::helper('vertnav')->__('Category Level %d', $i),
34
+ 'value' => $i,
35
+ );
36
+ }
37
+ $this->_options = $options;
38
+ }
39
+ return $this->_options;
40
+ }
41
+
42
+ public function getAllOptions()
43
+ {
44
+ return $this->toOptionArray();
45
+ }
46
+ }
app/code/community/RicoNeitzel/VertNav/etc/config.xml CHANGED
@@ -2,7 +2,7 @@
2
<config>
3
<modules>
4
<RicoNeitzel_VertNav>
5
- <version>0.2.3</version>
6
</RicoNeitzel_VertNav>
7
</modules>
8
@@ -12,6 +12,11 @@
12
<class>RicoNeitzel_VertNav_Block</class>
13
</vertnav>
14
</blocks>
15
<helpers>
16
<vertnav>
17
<class>RicoNeitzel_VertNav_Helper</class>
@@ -44,6 +49,9 @@
44
<display_product_count>0</display_product_count>
45
<expand_all>0</expand_all>
46
<expand_all_max_depth>0</expand_all_max_depth>
47
</vertnav>
48
</catalog>
49
</default>
2
<config>
3
<modules>
4
<RicoNeitzel_VertNav>
5
+ <version>0.2.7</version>
6
</RicoNeitzel_VertNav>
7
</modules>
8
12
<class>RicoNeitzel_VertNav_Block</class>
13
</vertnav>
14
</blocks>
15
+ <models>
16
+ <vertnav>
17
+ <class>RicoNeitzel_VertNav_Model</class>
18
+ </vertnav>
19
+ </models>
20
<helpers>
21
<vertnav>
22
<class>RicoNeitzel_VertNav_Helper</class>
49
<display_product_count>0</display_product_count>
50
<expand_all>0</expand_all>
51
<expand_all_max_depth>0</expand_all_max_depth>
52
+ <hide_top>1</hide_top>
53
+ <vertnav_root>root</vertnav_root>
54
+ <fallback_to_root>1</fallback_to_root>
55
</vertnav>
56
</catalog>
57
</default>
app/code/community/RicoNeitzel/VertNav/etc/system.xml CHANGED
@@ -10,11 +10,20 @@
10
<show_in_website>1</show_in_website>
11
<show_in_store>1</show_in_store>
12
<fields>
13
<display_product_count translate="label" module="vertnav">
14
<label>Display Product Count</label>
15
<frontend_type>select</frontend_type>
16
<source_model>adminhtml/system_config_source_yesno</source_model>
17
- <sort_order>10</sort_order>
18
<show_in_default>1</show_in_default>
19
<show_in_website>1</show_in_website>
20
<show_in_store>1</show_in_store>
@@ -23,7 +32,7 @@
23
<label>Expand all categories</label>
24
<frontend_type>select</frontend_type>
25
<source_model>adminhtml/system_config_source_yesno</source_model>
26
- <sort_order>20</sort_order>
27
<show_in_default>1</show_in_default>
28
<show_in_website>1</show_in_website>
29
<show_in_store>1</show_in_store>
@@ -31,12 +40,31 @@
31
<expand_all_max_depth translate="label,comment" module="vertnav">
32
<label>Expand all max depth</label>
33
<frontend_type>text</frontend_type>
34
- <sort_order>30</sort_order>
35
<show_in_default>1</show_in_default>
36
<show_in_website>1</show_in_website>
37
<show_in_store>1</show_in_store>
38
<comment>Leave empty or set to 0 for no limit</comment>
39
</expand_all_max_depth>
40
</fields>
41
</vertnav>
42
</groups>
10
<show_in_website>1</show_in_website>
11
<show_in_store>1</show_in_store>
12
<fields>
13
+ <hide_top translate="label" module="vertnav">
14
+ <label>Hide Top Navigation</label>
15
+ <frontend_type>select</frontend_type>
16
+ <source_model>adminhtml/system_config_source_yesno</source_model>
17
+ <sort_order>10</sort_order>
18
+ <show_in_default>1</show_in_default>
19
+ <show_in_website>1</show_in_website>
20
+ <show_in_store>1</show_in_store>
21
+ </hide_top>
22
<display_product_count translate="label" module="vertnav">
23
<label>Display Product Count</label>
24
<frontend_type>select</frontend_type>
25
<source_model>adminhtml/system_config_source_yesno</source_model>
26
+ <sort_order>20</sort_order>
27
<show_in_default>1</show_in_default>
28
<show_in_website>1</show_in_website>
29
<show_in_store>1</show_in_store>
32
<label>Expand all categories</label>
33
<frontend_type>select</frontend_type>
34
<source_model>adminhtml/system_config_source_yesno</source_model>
35
+ <sort_order>30</sort_order>
36
<show_in_default>1</show_in_default>
37
<show_in_website>1</show_in_website>
38
<show_in_store>1</show_in_store>
40
<expand_all_max_depth translate="label,comment" module="vertnav">
41
<label>Expand all max depth</label>
42
<frontend_type>text</frontend_type>
43
+ <sort_order>40</sort_order>
44
<show_in_default>1</show_in_default>
45
<show_in_website>1</show_in_website>
46
<show_in_store>1</show_in_store>
47
<comment>Leave empty or set to 0 for no limit</comment>
48
</expand_all_max_depth>
49
+ <vertnav_root translate="label" module="vertnav">
50
+ <label>Root Categories</label>
51
+ <frontend_type>select</frontend_type>
52
+ <source_model>vertnav/system_config_source_root</source_model>
53
+ <sort_order>50</sort_order>
54
+ <show_in_default>1</show_in_default>
55
+ <show_in_website>1</show_in_website>
56
+ <show_in_store>1</show_in_store>
57
+ </vertnav_root>
58
+ <fallback_to_root translate="label" module="vertnav">
59
+ <label>Fallback to store base</label>
60
+ <comment>If no current category is selected</comment>
61
+ <frontend_type>select</frontend_type>
62
+ <source_model>adminhtml/system_config_source_yesno</source_model>
63
+ <sort_order>60</sort_order>
64
+ <show_in_default>1</show_in_default>
65
+ <show_in_website>1</show_in_website>
66
+ <show_in_store>1</show_in_store>
67
+ </fallback_to_root>
68
</fields>
69
</vertnav>
70
</groups>
app/design/frontend/default/default/layout/vertnav.xml CHANGED
@@ -31,12 +31,29 @@
31
<reference name="head">
32
<action method="addItem"><type>skin_css</type><name>css/vertnav.css</name></action>
33
</reference>
34
- <!-- comment out the next three lines if you want to keep the top menu -->
35
<reference name="top.menu">
36
- <remove name="catalog.topnav"/>
37
</reference>
38
<reference name="left">
39
<block type="vertnav/navigation" name="catalog.vertnav" template="vertnav/left.phtml" before="-" />
40
</reference>
41
</default>
42
</layout>
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/default/default/template/vertnav/left.phtml CHANGED
@@ -34,7 +34,7 @@
34
?>
35
36
<div class="vertnav-container">
37
- <div class="header-nav">
38
<h4 class="no-display"><?php echo $this->__('Category Navigation:') ?></h4>
39
<ul id="vertnav">
40
<?php $store_categories = $this->toLinearArray($this->getStoreCategories()) ?>
34
?>
35
36
<div class="vertnav-container">
37
+ <div class="">
38
<h4 class="no-display"><?php echo $this->__('Category Navigation:') ?></h4>
39
<ul id="vertnav">
40
<?php $store_categories = $this->toLinearArray($this->getStoreCategories()) ?>
package.xml CHANGED
@@ -1,7 +1,7 @@
1
<?xml version="1.0"?>
2
<package>
3
<name>RicoNeitzel_VertNav</name>
4
- <version>0.2.3</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-09-24</date>
14
- <time>15:09:13</time>
15
- <contents><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="5835e51670d7bc57d61cfaa486a67c84"/></dir><dir name="template"><dir name="vertnav"><file name="left.phtml" hash="9a4f260c406a632e0d62e00504d686e3"/></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="1a8da8668f56e72d57ed8a422642343e"/></dir><dir name="etc"><file name="config.xml" hash="dbd4840ae78b642cbab79bec985f425c"/><file name="system.xml" hash="cc3572e09c725d5813b7fa47b780aee6"/></dir><dir name="Helper"><file name="Data.php" hash="8e340ac22d50a4ac719477a16a16a3e1"/></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.2.7</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>2009-10-03</date>
14
+ <time>22:34:23</time>
15
+ <contents><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="1c1186b9d0e0d6c22fc02350c52c6711"/><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>