zillo32 / vosao

Automatically exported from code.google.com/p/vosao
GNU Lesser General Public License v2.1
0 stars 0 forks source link

Selected page menu item - Superfish plugin #475

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
=The problem=
The current Superfish plugin does not provide the means to format a selected 
menu item (besides using a JavaScript workaround).

=Proposed solution=
Make `HttpServletRequest` available (through `org.vosao.common.VosaoContext`) 
to Superfish's velocity template, `menu.vm`, using the `$request` variable. 
From there, retrieve the top subdirectory of the current URI and add the 
`.selected` CSS class to its `<li>` HTML tag. This will allow the top level of 
the selected menu item to be formatted using CSS. For example, say the current 
page is `/foo/bar`, the 'foo' menu item would be selected.

The code I've written (see attached files) is probably a little sloppy, as I'm 
a bit of a Java newbie! Hopefully there's still some room for improvement, if 
there's interest!

Original issue reported on code.google.com by jmettes@gmail.com on 9 May 2011 at 5:08

Attachments:

GoogleCodeExporter commented 8 years ago
Using this plugin now. It definitely needs a lot of TLC (or time spent on it). 
Have made patches like the one above to show first and last list items in the 
html output. One "hack" i use for this to select the background is to use 
javascript to select the active node once the page has loaded and shade it in. 
Not as good as modifying the code, but it seems to work okayish.

<script type="text/javascript">
/*<![CDATA[*/
$(function() {
    $('#header-menu ul li:nth-child(1)').attr('id', 'current');
});
/*]]>*/
</script>

Original comment by rqu...@ebstrada.com.au on 26 Jul 2011 at 1:49

GoogleCodeExporter commented 8 years ago
Also, there needs to be a way to select the different menu styles for superfish 
without recompiling the code. Eg, dropdown menu or horizontal menu (see 
superfish examples).

Original comment by rqu...@ebstrada.com.au on 26 Jul 2011 at 1:52