Quick Nav:  Online Store   |   Login | Register

How to use the classes 'first' and 'last' in templates

Rate this topic:

Please Register to post a reply. Another benefit of registration is the ability to subscribe to and recieve notifications of new posts.
AuthorMessages
Pascal
<20 Posts
Posts:5


09/10/2007 6:07 AM  

Hello John,

Is it possible to use the classes 'first' and 'last' in a template? An instance of the CSSNavmenu not based on a template is generating these classes and I wonder if this is also possible using a template-file.

Thanks again,

Best regards,

Pascal

 

John Mitchell
Posts:3478


09/11/2007 6:36 AM  
Hi Pascal,
No, I do not currently have a way to detect first and last child in a template, but if you want to give me a few days I should be able to add that feature.

You may also be able to accomplish what you need by using the :first-child psuedo class in CSS.
http://www.w3.org/TR/css3-selectors/#structural-pseudos
Lee Sykes
<20 Posts
Posts:19


11/15/2007 10:04 AM  

Hi John,

Did you have any luck with this, I now need to remove a left border from the first menu item in just the main menu?

Thanks,

Lee

John Mitchell
Posts:3478


11/15/2007 10:13 AM  

Yes, the templates have a way to check for first and last child.

Just like the IIF({Tab.IsActive}='True' check that is in the sample templates, you can also use IIF({Tab.IsFirstChild}='True' and IIF({Tab.IsLastChild}='True'

Lee Sykes
<20 Posts
Posts:19


11/16/2007 8:03 AM  

Great thanks, - I have now starting experimenting with templates so that I can add the above check in. - Before adding the check I am just trying to get a template to output exactly the same as when you select the 'hover' nav type.

I took the suckerfish template and slightly changed it to:

(file attached)

 

The problem I am having is that some of the menu items are disappearing, the structure is as follows


Home
    Submenu 1
        SubSubmenu
    Submenu 2


When I hover over the Home page only Submenu 2 displays, the submenu1 and SuSubmenu do not display.

The menu works fine if the menu is set to use 'Hover' nav type - How can I get this template to work in exactly the same way as the hover type?

My CSS code is also below:

#nav, #nav ul
{
    /* all lists */
    padding: 0;
    margin: 0;
    list-style: none;
    line-height: 1;
    color: #fff;
    width: auto;
    background: url(images/Menubar_Main_Highlight.gif) no-repeat -1000px -1000px;
}

#nav a
{
    /* width: 10em; */ /* override link styling for menu */
    display: block;
    border-left: 1px solid #b6a2a2;
    border-right: 1px solid #331f1f;
    font-size: 12px;
    color: #fff;
    text-decoration: none;
    padding: 4px 8px 3px 8px;
}

#nav li
{
    /* all list items */
    float: left;
    width: auto; /* width needed or else Opera goes nuts */
    list-style: none;
}

#nav li ul
{
    /* second-level lists */
    position: absolute;
    width: 109px;
    left: -999em; /* using left instead of display to hide menus because display: none isn't read by screen readers */
    display: block;
    margin: 0;
    padding: 0;
}

/* styles each individual submenu item */
#nav li ul a
{
    border: 0;
    border: 0px;
    border-top: 1px solid #ffffff;
    border-bottom: 1px solid #2e2e2e;
    display: block;
    width: 109px;
    padding: 3px 3px 3px 4px;
    background: orange url(images/Subnav_Background.gif) repeat;
}

#nav li ul ul
{
    /* third-and-above-level lists */
    margin: -1.8em 0 0 10em;
}

/* hover for main menu */
#nav li a:hover
{
    background: #29599f url(images/Menubar_Main_Highlight.gif) repeat-x;
    color: #fff;
}

/* hover for sub menus and reset width of hover */
#nav li ul a:hover
{
    background: #29599f url(images/SubNav_Background_Highlight.gif) repeat-y center;
    color: #fff;
    width: 109px;
}

#nav li:hover ul ul, #nav li:hover ul ul ul,
#nav li.sfhover ul ul, #nav li.sfhover ul ul ul
{
    left: -999em;
}

#nav li:hover ul, #nav li li:hover ul, #nav li li li:hover ul,
#nav li.sfhover ul, #nav li li.sfhover ul, #nav li li li.sfhover ul
{
    /* lists nested under hovered list items */
    left: auto;
}

/* remove bold from selected menu item */
#nav .SelectedTab
{
    font-weight: normal;
}


Attachment: 1111645363654.txt

John Mitchell
Posts:3478


11/16/2007 8:12 AM  
It looks like your CSS has li.sfhover, but the onmouseover event in the template has just 'hover' as the class name:

So you can change this:
[${IEHoverJS}[ onmouseover="this.className+=' hover ';" onmouseout="this.className=this.className.replace(' hover ', '');" ]$]

To this:
[${IEHoverJS}[ onmouseover="this.className+=' sfhover ';" onmouseout="this.className=this.className.replace(' sfhover ', '');" ]$]

Lee Sykes
<20 Posts
Posts:19


11/16/2007 8:41 AM  

wow, somehow I had managed to lose the revised CSS code where I had changed the sf classes to ie classes. - So, the css is now using iehover and the code in the template also specifies iehover. The menu now hovers in IE6.

 

But I still have the same problem, The hover works, but it doesn't display submenu1 or the subsubmenu - it just displays submenu2 (This happens in all browsers)

John Mitchell
Posts:3478


11/16/2007 9:23 AM  
I think it may be this:
#nav li:hover ul, #nav li li:hover ul, #nav li li li:hover ul,
#nav li.sfhover ul, #nav li li.sfhover ul, #nav li li li.sfhover ul
{
/* lists nested under hovered list items */
left: auto;
}


I have this in the sample:
#nav li li:hover ul,
#nav li li li:hover ul,
#nav li li.iehover ul,
#nav li li li.iehover ul {
top: 0;
left:12.8em;
}

The left:auto; may not be working.
Lee Sykes
<20 Posts
Posts:19


11/16/2007 9:50 AM  

Changing those values just re-positions the hover menu, but I still only have submenu2 displaying. - What is odd is that this CSS code worked fine using the 'hover' menu type, the problem only occurs when I have switched to this template.

John Mitchell
Posts:3478


11/16/2007 9:55 AM  
Oh, ok. Can you put the output html from both types into a text file and attach it? We should be able to spot the difference there.
Lee Sykes
<20 Posts
Posts:19


11/16/2007 10:06 AM  

the 2 different source codes from my dnn installs are attached, thanks


Attachment: 1111661530858.txt

John Mitchell
Posts:3478


11/19/2007 1:54 PM  
Hi Lee,
Did you get any further on this? I've been trying to recreate it with just the output, but so far I haven't got it to work.
There isn't any difference in the actual menu output that I can tell, so I'm thinking that maybe the combined CSS files from two different installs are causing something diferent to happen.

Lee Sykes
<20 Posts
Posts:19


11/22/2007 4:12 AM  

Hi John,

No I didn't get it to work after several hours of playing with it.  So I referred back to the original hover method which works without any problems and I then targeted the first menu item by the Tabs Nav ID

Thanks,

Tresken
<20 Posts
Posts:3


12/10/2007 7:26 AM  

Hello john,

I'v tried to make the IfFirstChild statement work, but it only put's out False. here is my code:

 

[NavMenu-Container[

    ]]
        [Level1-Item[
  • IIF({Tab.IsFirstChild}='True', first, notfirst)
  • ]]
                [Level1-Anchor[ {Tab.Name} ]]
        [/Level1-Item[
  • ]]
        [Level2-Item[
  • ]]
                [Level2-Anchor[ {Tab.Name} ]]
        [/Level2-Item[
  • ]]
    [/NavMenu-Container[
]]

 

So only "notfirst" is printed on the page, the rest works great. Could you me out here?

Thank,

Best regards, Thomas de Wit

John Mitchell
Posts:3478


12/10/2007 8:07 AM  

Hi Tresken,

You may have an older version of the menu. Send me an e-mail by replying directly to the notification of this post, or by clicking on my username here in the forums, and I'll send you the latest.

Tresken
<20 Posts
Posts:3


12/10/2007 9:17 AM  

Hi John,

I'v reply'd to the notification mail, so you should have my email. According to my colleague we have version 3.1.2 , wich should be one of the latetst versions if i'm correct.

Regards, Thomas

Please Register to post a reply. Another benefit of registration is the ability to subscribe to and recieve notifications of new posts.
Forums >Snapsis Product Support >CSS NavMenu > How to use the classes 'first' and 'last' in templates



ActiveForums 3.7
Powered by: Snapsis Software