Last items of menu different css class

This is a forum to suggest new features for mojoPortal. 

This thread is closed to new posts. You must sign in to post in the forums.
11/22/2009 3:14:38 AM
Nux
Gravatar
Total Posts 183

Last items of menu different css class

Hey Joe,

would it be possible to give the last li from a menu a different style?
Cause when you use some seperators (mostly done in css with a background image), you can't disable it for the last item since it's the same as the rest.
I guess that will not be that difficult, but helpfull ;)

Thanks
Stef

11/24/2009 2:03:32 PM
Gravatar
Total Posts 18439

Re: Last items of menu different css class

No, I do not know a way to do that. When the menu renders there is no indicator or event that can be used to determine if some node is the last one especially because there may be multiple levels of menu showing just a sub tree of a site like on this site where we have 2 horizontal and one vertical menu.

Sorry,

Joe

11/24/2009 2:21:19 PM
Nux
Gravatar
Total Posts 183

Re: Last items of menu different css class

Hey Joe,

I don't understand why you can't do that.
You know the datasource of your repeater, so you know how many items there are.
If you declare a variable outside the ItemDataBound, and increase this variable in the itemDatabound, you will get the last if the variable has the same value as the numbers of items in the datasource (if the start value of the variable is 1), not?

Stef

11/24/2009 2:45:01 PM
Gravatar
Total Posts 18439

Re: Last items of menu different css class

Its not a repeater and we are not simply binding to rows it is a hierarchal tree of sitemap nodes. It is more complicated than you may think. You would have to keep track of nodes at the depth that is the top level of the menu and the css classes are assigned deep inside the menu control adapters not in the menu as it is databinding.

I will ponder it but it's not a trivial request as you may think.

Best,

Joe

11/24/2009 3:08:58 PM
Nux
Gravatar
Total Posts 183

Re: Last items of menu different css class

Ok, I thought it was easier Smile.
If you could find a way, it would be great, but I can understand that there are more important things that this one.

Thanks Joe for the explanation.

Stef

11/24/2009 3:32:48 PM
Gravatar
Total Posts 18439

Re: Last items of menu different css class

fyi, this post on stackoverflow is relevant, and it points to what looks like an easy jQuery solution to the problem.

Best,

Joe

11/25/2009 3:18:30 AM
Nux
Gravatar
Total Posts 183

Re: Last items of menu different css class

Hey Joe,

thanks for this. I will try it this evening.

Stef

4/13/2011 11:43:33 AM
Gravatar
Total Posts 63
Jerry McCreary
SureFire Studios, Inc.

Re: Last items of menu different css class

Joe,

This may be the same question from Nux ...

Is there a way to add a css class to the first child and a class to the last child?

Ex:

<ul>

   <li class="item first"><a href="#">Page 1</a></li>

   <li class="item"><a href="#">Page 2</a></li>

   <li class="item last"><a href="#">Page 3</a></li>

</ul>

 

I'm converting a client's site to mojoportal, and have been looking for a way to do that, in order to match their current design.

(Sorry if this is in the wrong forum)

 

4/13/2011 11:49:01 AM
Gravatar
Total Posts 18439

Re: Last items of menu different css class

The menu nor Treeview controls don't really have anything to detect whether a node is the first or last one so they don't render any different css based on that kind of logic.

However as of mojoPortal 2.3.6.4 we do support custom css classes per page on the body element and on the menu item, so you could manually specify a custom css class for the first and/or last page in your menu.

Hope it helps,

Joe

4/13/2011 1:19:43 PM
Gravatar
Total Posts 63
Jerry McCreary
SureFire Studios, Inc.

Re: Last items of menu different css class

That will probably work.  Thanks.

4/14/2011 2:34:45 PM
Gravatar
Total Posts 355

Re: Last items of menu different css class

Jerry,

Just bouncing through quickly - have a look at http://www.southernbells4equality.com - I used CSS selectors to set a different color for each menu item according to the order of the desired colors.  Is that the kind of thing you're looking for?

You must sign in to post in the forums. This thread is closed to new posts.