RicoNeitzel_VertNav - Version 0.4.0

Version Notes

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

0.4.0: Added Feature Expand on Top Level Request: If a product is requested without categories in the URL vert nav can figure out the first assigned category and expands the category tree

Download this release

Release Info

Developer Vinai Kopp
Extension RicoNeitzel_VertNav
Version 0.4.0
Comparing to
See all releases


Code changes from version 0.3.1 to 0.4.0

app/code/community/RicoNeitzel/VertNav/Block/Navigation.php CHANGED
@@ -45,7 +45,7 @@ class RicoNeitzel_VertNav_Block_Navigation extends Mage_Catalog_Block_Navigation
45
  {
46
  $key = parent::getCacheKey();
47
  $customerGroupId = $this->_getCustomerGroupId();
48
- $productId = Mage::registry('current_product') ? Mage::registry('current_product') : 0;
49
  $cmsPageId = Mage::app()->getRequest()->getParam('page_id', Mage::getStoreConfig(Mage_Cms_Helper_Page::XML_PATH_HOME_PAGE));
50
 
51
  return 'VERTNAV_' . $key . '_' . $customerGroupId . '_' . $productId . '_' . $cmsPageId;
@@ -118,6 +118,7 @@ class RicoNeitzel_VertNav_Block_Navigation extends Mage_Catalog_Block_Navigation
118
 
119
  if ($this->_checkLoginCatalog()) return '';
120
  if (! $category->getIsActive()) return '';
 
121
 
122
  if (! isset($levelClass)) $levelClass = array();
123
  $combineClasses = array();
@@ -134,13 +135,13 @@ class RicoNeitzel_VertNav_Block_Navigation extends Mage_Catalog_Block_Navigation
134
  $levelClass[] = implode('-', $combineClasses);
135
 
136
  $levelClass = array_merge($levelClass, $combineClasses);
137
-
138
  $levelClass[] = $this->_getClassNameFromCategoryName($category);
139
-
140
  $productCount = '';
141
  if ($this->displayProductCount())
142
  {
143
- $n = $this->_getProductCount($category);
144
  $productCount = '<span class="product-count"> (' . $n . ')</span>';
145
  }
146
 
@@ -149,14 +150,14 @@ class RicoNeitzel_VertNav_Block_Navigation extends Mage_Catalog_Block_Navigation
149
 
150
  $autoMaxDepth = Mage::getStoreConfig('catalog/vertnav/expand_all_max_depth');
151
  $autoExpand = Mage::getStoreConfig('catalog/vertnav/expand_all');
152
-
153
  if (in_array($category->getId(), $this->getCurrentCategoryPath())
154
  || ($autoExpand && $autoMaxDepth == 0)
155
  || ($autoExpand && $autoMaxDepth > $level+1)
156
  ) {
157
  $children = $this->_getCategoryCollection()
158
  ->addIdFilter($category->getChildren());
159
-
160
  $children = $this->toLinearArray($children);
161
 
162
  //usort($children, array($this, '_sortCategoryArrayByName'));
@@ -201,7 +202,7 @@ class RicoNeitzel_VertNav_Block_Navigation extends Mage_Catalog_Block_Navigation
201
 
202
  // indent HTML!
203
  $html[3] = "\n".str_pad ( "", ($level * 2 ) + 2, " " ).'</li>'."\n";
204
-
205
  ksort($html);
206
  return implode('', $html);
207
  }
@@ -322,6 +323,19 @@ class RicoNeitzel_VertNav_Block_Navigation extends Mage_Catalog_Block_Navigation
322
  /* @var $category Mage_Catalog_Model_Category */
323
  $category = Mage::getModel('catalog/category');
324
 
 
 
 
 
 
 
 
 
 
 
 
 
 
325
  $parent = false;
326
  switch (Mage::getStoreConfig('catalog/vertnav/vertnav_root'))
327
  {
@@ -359,7 +373,7 @@ class RicoNeitzel_VertNav_Block_Navigation extends Mage_Catalog_Block_Navigation
359
  /**
360
  * Thanks to thebod for this patch!
361
  * It enables the setting of the category ID to use via Layout XML:
362
- *
363
  * <reference name="catalog.vertnav">
364
  * <action method="setCategoryId"><category_id>8</category_id></action>
365
  * </reference>
@@ -367,7 +381,7 @@ class RicoNeitzel_VertNav_Block_Navigation extends Mage_Catalog_Block_Navigation
367
  if ($customId = $this->getCategoryId()) {
368
  $parent = $customId;
369
  }
370
-
371
  if (! $parent && Mage::getStoreConfig('catalog/vertnav/fallback_to_root'))
372
  {
373
  $parent = Mage::app()->getStore()->getRootCategoryId();
@@ -382,7 +396,7 @@ class RicoNeitzel_VertNav_Block_Navigation extends Mage_Catalog_Block_Navigation
382
  }
383
  $storeCategories = $this->_getCategoryCollection()
384
  ->addFieldToFilter('parent_id', $parent);
385
-
386
  $this->_storeCategories = $storeCategories;
387
  return $storeCategories;
388
  }
@@ -408,7 +422,7 @@ class RicoNeitzel_VertNav_Block_Navigation extends Mage_Catalog_Block_Navigation
408
  {
409
  $collection->setLoadProductCount(true);
410
  }
411
-
412
  return $collection;
413
  }
414
 
45
  {
46
  $key = parent::getCacheKey();
47
  $customerGroupId = $this->_getCustomerGroupId();
48
+ $productId = Mage::registry('current_product') ? Mage::registry('current_product')->getId() : 0;
49
  $cmsPageId = Mage::app()->getRequest()->getParam('page_id', Mage::getStoreConfig(Mage_Cms_Helper_Page::XML_PATH_HOME_PAGE));
50
 
51
  return 'VERTNAV_' . $key . '_' . $customerGroupId . '_' . $productId . '_' . $cmsPageId;
118
 
119
  if ($this->_checkLoginCatalog()) return '';
120
  if (! $category->getIsActive()) return '';
121
+ if (! $category->getIncludeInMenu()) return '';
122
 
123
  if (! isset($levelClass)) $levelClass = array();
124
  $combineClasses = array();
135
  $levelClass[] = implode('-', $combineClasses);
136
 
137
  $levelClass = array_merge($levelClass, $combineClasses);
138
+
139
  $levelClass[] = $this->_getClassNameFromCategoryName($category);
140
+
141
  $productCount = '';
142
  if ($this->displayProductCount())
143
  {
144
+ $n = Mage::getModel('catalog/layer')->setCurrentCategory($category->getID())->getProductCollection()->getSize();
145
  $productCount = '<span class="product-count"> (' . $n . ')</span>';
146
  }
147
 
150
 
151
  $autoMaxDepth = Mage::getStoreConfig('catalog/vertnav/expand_all_max_depth');
152
  $autoExpand = Mage::getStoreConfig('catalog/vertnav/expand_all');
153
+
154
  if (in_array($category->getId(), $this->getCurrentCategoryPath())
155
  || ($autoExpand && $autoMaxDepth == 0)
156
  || ($autoExpand && $autoMaxDepth > $level+1)
157
  ) {
158
  $children = $this->_getCategoryCollection()
159
  ->addIdFilter($category->getChildren());
160
+
161
  $children = $this->toLinearArray($children);
162
 
163
  //usort($children, array($this, '_sortCategoryArrayByName'));
202
 
203
  // indent HTML!
204
  $html[3] = "\n".str_pad ( "", ($level * 2 ) + 2, " " ).'</li>'."\n";
205
+
206
  ksort($html);
207
  return implode('', $html);
208
  }
323
  /* @var $category Mage_Catalog_Model_Category */
324
  $category = Mage::getModel('catalog/category');
325
 
326
+ /* Set Category Object if Product is requested without category path in URI (top level request). Takes first Category of a Product as Category Object*/
327
+
328
+ if( true == (bool) Mage::getStoreConfig( 'catalog/vertnav/show_cat_on_toplevel' ) &&
329
+ false == Mage::registry('current_category') &&
330
+ false != Mage::registry('current_product') ) {
331
+ $product_categories = Mage::registry( 'current_product' )->getCategoryIds();
332
+ if(count($product_categories) > 0) {
333
+ $new_active_category = Mage::getModel('catalog/category')->load($product_categories[0]);
334
+ Mage::register('current_category', $new_active_category);
335
+ }
336
+ }
337
+
338
+
339
  $parent = false;
340
  switch (Mage::getStoreConfig('catalog/vertnav/vertnav_root'))
341
  {
373
  /**
374
  * Thanks to thebod for this patch!
375
  * It enables the setting of the category ID to use via Layout XML:
376
+ *
377
  * <reference name="catalog.vertnav">
378
  * <action method="setCategoryId"><category_id>8</category_id></action>
379
  * </reference>
381
  if ($customId = $this->getCategoryId()) {
382
  $parent = $customId;
383
  }
384
+
385
  if (! $parent && Mage::getStoreConfig('catalog/vertnav/fallback_to_root'))
386
  {
387
  $parent = Mage::app()->getStore()->getRootCategoryId();
396
  }
397
  $storeCategories = $this->_getCategoryCollection()
398
  ->addFieldToFilter('parent_id', $parent);
399
+
400
  $this->_storeCategories = $storeCategories;
401
  return $storeCategories;
402
  }
422
  {
423
  $collection->setLoadProductCount(true);
424
  }
425
+
426
  return $collection;
427
  }
428
 
app/code/community/RicoNeitzel/VertNav/etc/config.xml CHANGED
@@ -23,7 +23,7 @@
23
  <config>
24
  <modules>
25
  <RicoNeitzel_VertNav>
26
- <version>0.3.1</version>
27
  </RicoNeitzel_VertNav>
28
  </modules>
29
 
23
  <config>
24
  <modules>
25
  <RicoNeitzel_VertNav>
26
+ <version>0.4.0</version>
27
  </RicoNeitzel_VertNav>
28
  </modules>
29
 
app/code/community/RicoNeitzel/VertNav/etc/system.xml CHANGED
@@ -67,6 +67,16 @@
67
  <show_in_store>1</show_in_store>
68
  <comment>Leave empty or set to 0 for no limit</comment>
69
  </expand_all_max_depth>
 
 
 
 
 
 
 
 
 
 
70
  <vertnav_root translate="label" module="vertnav">
71
  <label>Root Categories</label>
72
  <frontend_type>select</frontend_type>
67
  <show_in_store>1</show_in_store>
68
  <comment>Leave empty or set to 0 for no limit</comment>
69
  </expand_all_max_depth>
70
+ <show_cat_on_toplevel translate="label,comment" module="vertnav">
71
+ <label>Expand on Top Level</label>
72
+ <frontend_type>select</frontend_type>
73
+ <source_model>adminhtml/system_config_source_yesno</source_model>
74
+ <sort_order>30</sort_order>
75
+ <show_in_default>1</show_in_default>
76
+ <show_in_website>1</show_in_website>
77
+ <show_in_store>1</show_in_store>
78
+ <comment>If your product is top level requested without a category path should VertNav expand the category listing to the first associated product category.</comment>
79
+ </show_cat_on_toplevel>
80
  <vertnav_root translate="label" module="vertnav">
81
  <label>Root Categories</label>
82
  <frontend_type>select</frontend_type>
app/locale/de_DE/RicoNeitzel_VertNav.csv CHANGED
@@ -1,4 +1,4 @@
1
- "Display Product Count","Produktanzahl Anzeigen"
2
  "Expand all categories","Alle Kategorien öffnen"
3
  "Expand all max depth","Alle öffnen bis max. Tiefe"
4
  "Leave empty or set to 0 for no limit","Leer lassen oder auf 0 setzen für keine Einschränkung"
@@ -9,4 +9,6 @@
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"
 
 
1
+ "Display Product Count","Artikelanzahl anzeigen"
2
  "Expand all categories","Alle Kategorien öffnen"
3
  "Expand all max depth","Alle öffnen bis max. Tiefe"
4
  "Leave empty or set to 0 for no limit","Leer lassen oder auf 0 setzen für keine Einschränkung"
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
+ "Expand on Top Level","Aufklappen, wenn Artikel direkt aufgerufen wird"
14
+ "If a product is top level requested without a category path should VertNav expand the category listing to the first associated category.","Soll der Kategoriebaum zur ersten, dem Artikel zugewiesenen Kategorie aufgeklappt werden, wenn der Artikel direkt (ohne Kategoriepfad in der URL) aufgerufen wurde?"
package.xml CHANGED
@@ -1,18 +1,20 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>RicoNeitzel_VertNav</name>
4
- <version>0.3.1</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Vertical Navigation - drop in replacement for the horizontal top navigation.</summary>
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>2011-07-01</date>
14
- <time>09:47:44</time>
15
- <contents><target name="magecommunity"><dir name="RicoNeitzel"><dir name="VertNav"><dir name="Block"><file name="Navigation.php" hash="940b4d2df80832e116e8e94cc2132b05"/></dir><dir name="Helper"><file name="Data.php" hash="a3995193a1ce5560edbd95e11720ce8b"/></dir><dir name="Model"><dir name="System"><dir name="Config"><dir name="Source"><file name="Root.php" hash="20696bf2dfef3e1092d7c08caf1dbc8e"/></dir></dir></dir></dir><dir name="etc"><file name="config.xml" hash="fe162a257b72b1fb21f182b59f44c303"/><file name="system.xml" hash="6008ceee34063d9cb0c6779993af2cfa"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="RicoNeitzel_VertNav.xml" hash="227d7980c24ebd629e1c1d4f10b8c62c"/></dir></target><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="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="e2f0d7e286ad1d3caadd4892fbb0671f"/></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="e2f0d7e286ad1d3caadd4892fbb0671f"/></dir></dir></dir></dir></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></contents>
 
 
16
  <compatible/>
17
- <dependencies/>
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>RicoNeitzel_VertNav</name>
4
+ <version>0.4.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>
8
  <extends/>
9
  <summary>Vertical Navigation - drop in replacement for the horizontal top navigation.</summary>
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.&#xD;
12
+ &#xD;
13
+ 0.4.0: Added Feature Expand on Top Level Request: If a product is requested without categories in the URL vert nav can figure out the first assigned category and expands the category tree</notes>
14
+ <authors><author><name>Vinai Kopp</name><user>vinai</user><email>vinai@netzarbeiter.com</email></author><author><name>Rico Neitzel</name><user>rizi</user><email>rico@buro71a.de</email></author></authors>
15
+ <date>2012-09-03</date>
16
+ <time>08:55:15</time>
17
+ <contents><target name="magecommunity"><dir name="RicoNeitzel"><dir name="VertNav"><dir name="Block"><file name="Navigation.php" hash="2a1dbd73a8d665a34ad2e31abea39749"/></dir><dir name="Helper"><file name="Data.php" hash="a3995193a1ce5560edbd95e11720ce8b"/></dir><dir name="Model"><dir name="System"><dir name="Config"><dir name="Source"><file name="Root.php" hash="20696bf2dfef3e1092d7c08caf1dbc8e"/></dir></dir></dir></dir><dir name="etc"><file name="config.xml" hash="eea44d143acdf63090d1206b7ae6b089"/><file name="system.xml" hash="8341b6dc4b1894f7ce0b5241aa8ba547"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="RicoNeitzel_VertNav.xml" hash="227d7980c24ebd629e1c1d4f10b8c62c"/></dir></target><target name="magelocale"><dir name="de_DE"><file name="RicoNeitzel_VertNav.csv" hash="85bf4aa9c2b81187ab5e1c8f62a35110"/></dir><dir name="es_MX"><file name="RicoNeitzel_VertNav.csv" hash="54b83643165bc5b72ca8ce2122fd5422"/></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="e2f0d7e286ad1d3caadd4892fbb0671f"/></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="e2f0d7e286ad1d3caadd4892fbb0671f"/></dir></dir></dir></dir></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></contents>
18
  <compatible/>
19
+ <dependencies><required><php><min>5.2.6</min><max>6.0.0</max></php></required></dependencies>
20
  </package>