Author Topic: VM Category Menu to display in Flat List format (with opened child items)  (Read 5335 times)

hikaru

  • Beginner
  • *
  • Posts: 5
Searching through forums and google, I couldn't come across with any solution to show VM Category Menu in Flat List Format, with always opened child menu items.

Desired output format is simple, just like the Flat List option available in Joomla Menu Module:
Code: [Select]
<ul>
  <li><a>Parent Menu</a></li>
  <ul>
    <li><a>Child Menu 1</a></li>
    <li><a>Child Menu 2</a></li>
  </ul>
</ul>

I found few solutions that outputs VM Category Menu in lists, but none of them can have Child Menu opened by default (they only opens once its parent menu is clicked)

The closest I came across with was Virtuemart Category List Module by "phoca", that has flat output of parent menu and child menus (which I've customised to output in List Style). However, the output doesn't have hierarchy and there's no possibility to differentiate the style between the parent and child menus.

I'd greatly appreciate if anyone can share me any options or ideas to achieve this. Thank you
Virtuemart 1.1.3
Joomla 1.5.10
Artio 3.2.12 + Virtuemart Extension 2.01

andpatton

  • Beginner
  • *
  • Posts: 32
    • acusti.ca
***Update 27-04-2010: I attached the latest version of the module to this post, which adds a number of useful features, improved SEF url functionality, and includes one bug fix. I may not remember to do this in future releases, so please download the module from either the extensions directory (link below) or on the Joomla Extensions Directory

***Update 08-09-2009: I submitted the module to the VM extensions directory. You can view and download it here: VirtueMart Full Category List Module

***Update 31-08-2009: I attached a new copy of the module that only displays categories that are published (and removed the old copy).

I had the same problem, and after much googling finally found this promising option:
Pure CSS Virtuemart category module, which was just what I was looking for. To quote:
Quote from:  El-Tech
This simple and easy to use Joomla module... displays the category and sub-categories under a ul list structure

The problem is it's only for J! 1.0, so I took the liberty of updating it for J!1.5, and realized I should also add support for another level of sub-categories, fix some tag closing, optimize the code a bit, and add in css class suffix parameters to make it maximally customizable and style-able.

I've attached the package. Just install it as normal in the Joomla installer, then create a new module of type "VM Full Category List", assign it to a module position in your template, enable it, and you should be good to go!

One word of warning: this will only display categories, subcategories, and sub-subcategories (ie, three levels of categories)  but it doesn't go any deeper than that. If you need it to, I could fairly easily expand it to do so, so just post a reply saying how many levels of categories you need to display, and I can try to make that possible (or you can pretty easily do it yourself, if you know anything about php).

Good luck, and I hope this helps



[attachment cleanup by admin]

Piszi

  • Jr. Member
  • **
  • Posts: 58

***Update 31-08-2009: I attached a new copy of the module that only displays categories that are published (and removed the old copy).



There is a little bug in it.
It can't handle UTF-8 category names and returns disorted chars.

So, if somebody have special chars in the category name than delete the htmlentities() function.

the modified code looks like this
Code: [Select]
echo '<li><a class="level' . $level . $menuClass.'" href="'.$link.'" target="_self">'.$row->category_name.'</a>';
Or use htmlspecialchars() instead of htmlentities()

This is a very good extension. Thank you.

andpatton

  • Beginner
  • *
  • Posts: 32
    • acusti.ca
Yes, someone else alerted me to that problem -- I actually fixed it to be utf-8 compatible (and the person who originally told me about the problem said the fix worked), but I hadn't got around to updating it on the site (there were a couple other features I wanted to implement in the same update. Perhaps I'll just put it up as a very minor update, but I'd like to wait longer to make an update -- so here's a compromise, I'll just upload the UTF-8 compatible version here.

Please let me know if this fix doesn't work for you, and thanks for the feedback.

Edit: I just saw that you posted a solution almost at the same time as me. I decided to change the line in this way (in order to maintain xhtml compliance), using htmlspecialchars() and it's optional third parameter:

Code: [Select]
echo '<li><a class="level' . $level . $menuClass.'" href="'.$link
.'" target="_self">'.htmlspecialchars($row->category_name, ENT_COMPAT, 'UTF-8').'</a>';

Also, I updated the encoding declaration on the .xml file.


[attachment cleanup by admin]

baru

  • Beginner
  • *
  • Posts: 10
Re: VM Category Menu to display in Flat List format (with opened child items)
« Reply #4 on: December 14, 2009, 07:08:16 am »
thaks..i will try, i hope it working for my site:)