Quick Nav:  Online Store   |   Login | Register
PrevPrev--NextNext
IsLastChild in multiple level menu templates
Last Post 15 Jul 2010 11:24 AM by Jason. 17 Replies.
Please Register to participate.
Sort: Print topic: Printer Friendly
AuthorMessagesNot Resolved
e-motion
New Member
Posts:11


Send PM:Send Private Message

--
01 Mar 2010 09:42 PM
Hi there,

I've hit a bit of an issue with using IsLastChild on Level0 items in my template, it seems that IsLastChild evaluates to True on all but the first item. It works as expected - only being applied to the last item - at all other levels. I'm 90% sure my template code is ok in which case maybe this is a bug or maybe the IsFirstChild/IsLastChild checks were not intended to be used on Level0 items.

I've created a template that outputs the same HTML as the Hover NavType (which was almost everything I needed) and then went about including the IsFirstChild/IsLastChild checks on each Level*-Item, eg:

[Level0-Item[ <li id="{NavMenu.Id}{Tab.Id}" class="IIF({Tab.IsFirstChild}='True',first-item) IIF({Tab.IsLastChild}='True',last-item) IIF({Tab.IsActive}='True',SelectedItem)" ...(more in here)... > ]]

...

[Level1-Item[ <li id="{NavMenu.Id}{Tab.Id}" class="IIF({Tab.IsFirstChild}='True',first-item) IIF({Tab.IsLastChild}='True',last-item) IIF({Tab.IsActive}='True',SelectedItem)" ...(more in here)... > ]]

The code for Level 0 and Level 1 Items(and any other Level for that matter) is identical, though maybe a fresh pair of eyes can point out a mistake I've made. I also have an alternate template where Level1 is the nav container for use in a sub menu - in every other place at every other level my classes are applied as expected, but Level 0 items as above have the class first-item applied to the first li and the class last-item is applied to every other li (2nd, 3rd, 4th... etc).

I'm sorry I can't give a live example as it's on a dev server at the moment, I'm using NavMenu 3.4.1 with a developer license. I'd prefer not to paste my entire template in here but can provide it via PM for testing if that'd help to try to reproduce the issue.

Any help would be greatly appreciated.

Cheers
Jessica
John Mitchell
Veteran Member
Posts:4350

Avatar

Administrator
Send PM:Send Private Message

--
02 Mar 2010 06:42 AM
Hi Jessica,
Thanks for the detailed explanation.
I'll look into this and get back to you today.
John Mitchell
Veteran Member
Posts:4350

Avatar

Administrator
Send PM:Send Private Message

--
02 Mar 2010 06:13 PM
Ok, I have attached a new DLL that should fix this bug.

Please drop the DLL in your /bin folder to test.
e-motion
New Member
Posts:11


Send PM:Send Private Message

--
04 Mar 2010 06:32 PM
Hi John,

Thanks so much for the prompt response, I'm only just back to try it out today. I dropped in your dll and tried a couple tests. Now it seems the IsLastChild is never True on Level0 items - still works fine on other levels as before. As a test I used the following:

IIF({Tab.IsLastChild}='True',last-item,not-last-item)

On Level0 every item had the not-last-item class applied, on Level 1 all but the last item had not-last-item applied and the last item appropriately had last-item. If I can provide any other information to help just let me know, I'm happy to help.

Also can I ask what is probably a novice question - I've seen references to Page.Condition and Tab.Condition, both seem to work with IsLastChild, is there any difference or is it just backwards compatibility with the old scheme of calling pages tabs?

Thanks,
Jessica
John Mitchell
Veteran Member
Posts:4350

Avatar

Administrator
Send PM:Send Private Message

--
05 Mar 2010 06:49 AM
Hi Jessica,
That is strange, it worked in my test. I'll check this again today.

You are correct, Page and Tab are both allowed because they used to be called tabs.
John Mitchell
Veteran Member
Posts:4350

Avatar

Administrator
Send PM:Send Private Message

--
11 Mar 2010 04:42 PM
Hi Jessica,
Sorry for the delay. That one took a while to track down.
It turns out it was only the last-child on the root level that wasn't getting set, so I took a little too much out on the last update.

I have attached a new one that should work correctly.
e-motion
New Member
Posts:11


Send PM:Send Private Message

--
15 Mar 2010 10:52 PM
Hi John,

The new file is spot on, thanks a lot for your help, I really appreciate the updates.

Just out of interest, will this update be included in future releases? If so I'll keep my eye out, it'd be great to have an official version with this fix to install in one go.

Thanks again,
Jessica
e-motion
New Member
Posts:11


Send PM:Send Private Message

--
17 Mar 2010 06:50 PM
Hi again John,

Unfortunately I've found the same issue in a Level1 sub menu but the good news is I seem to have narrowed down the circumstances for it happening.

It appears that {Tab.IsLastChild} evaluates to True when a menu item has child items below it, even if it is not the last child of the Level it is a part of. The issue I originally described fits this pattern - I was seeing the last-child class being applied to all but the first Level0 menu items, which all had at least one Level1 menu item associated with them. eg:

* Item1 - first-child
* Item2 - last-child
** Item 2.1
** Item 2.2
* Item3 - last-child
** Item 3.1
* Item4 - last-child

- If you remove Item3.1, the last-child class disappears from Item3

The new occurrence is in a submenu I have displaying Levels1-4. Only one of the Level 1 items has Level 2 items below it, it also happens to be the first Level1 item and so has both the first-item and last-item classes applied. I've tested re-ordering menus and also removing child menu items and can now see the pattern. I also tested the original DLL I had been using before your fixes and it's the same issue there.

Once again, I hope that this info helps, it seems to be on the right track to finding a root cause and not just a single level issue, if I can provide any more information just let me know.

Cheers,
Jessica
John Mitchell
Veteran Member
Posts:4350

Avatar

Administrator
Send PM:Send Private Message

--
19 Mar 2010 08:26 AM
Hi Jessica,
Thanks you for your patience and detailed explanations.

I have attached another update.
If you can test it out in all your cases I would appreciate it, and yes, I will be making a new complete package available.
e-motion
New Member
Posts:11


Send PM:Send Private Message

--
21 Mar 2010 07:41 PM
Hi John,

I've tested the new DLL and all seems to be well in my test cases - a Level0-1 "mainmenu" and Level1-3 "submenu". Thanks again for your help and prompt responses.

Cheers,
Jessica
John Mitchell
Veteran Member
Posts:4350

Avatar

Administrator
Send PM:Send Private Message

--
22 Mar 2010 12:41 PM
Thank you Jessica.

I'll get a new package put together for download.

e-motion
New Member
Posts:11


Send PM:Send Private Message

--
30 Mar 2010 12:53 AM
Sorry John, I've found another edge case that I hadn't come across in my testing. We may have over-fixed the previous issue of the last-item class being applied to any items that have a submenu below them.

I've now noticed that if the last item at a particular level has a sub menu below it, it doesn't get the last-item class anymore. eg:

Example 1: all good
* Item 1 - first-item
*** Item 1.1 - first-item
*** Item 1.2 -
*** Item 1.3 - last-item
* Item 2 -
*** Item 2.1 - first-item last-item
* Item 3 - last-item

Example 2: adding sub items to Item 3 - Item 3 loses it's last-item class
* Item 3 -
*** Item 3.1 - first-item
*** Item 3.2 - last-item

Cheers,
Jessica
e-motion
New Member
Posts:11


Send PM:Send Private Message

--
24 May 2010 11:09 PM
Hi John,

Just wondering if you have had a chance to revisit the most recent IsLastChild issues explained above? I'd really like to continue using this property and I can see a number of other posts from interested people looking to apply a first-item/last-item style class within their menu for styling. As always I'm happy to help with testing so that your module is as robust as possible for everyone.

Thanks,
Jessica
John Mitchell
Veteran Member
Posts:4350

Avatar

Administrator
Send PM:Send Private Message

--
25 May 2010 10:29 AM
Hi Jessica,
Thanks for bringing this back to my attention. I was planning on getting back to this one and let it slip off my radar. I'll get it fixed now.
John Mitchell
Veteran Member
Posts:4350

Avatar

Administrator
Send PM:Send Private Message

--
25 May 2010 11:43 AM
This scenario works in my current version (3.4.6)
I thought that was the last I gave you, but I'll attach it again now to make sure.
Jason
New Member
Posts:12


Send PM:Send Private Message

--
15 Jul 2010 10:42 AM
Where can I find this DLL to replace as I am having the same issue - ie, lastchild condition being falsely evaluated as true when a menu item has a sublevel.

Thanks!
Snapsis Staff
Posts:239

Avatar

Send PM:Send Private Message

--
15 Jul 2010 11:10 AM
Hi Jason,
I just sent the latest to you.
Let me know if you don't get it.
Jason
New Member
Posts:12


Send PM:Send Private Message

--
15 Jul 2010 11:24 AM
I just got it, however this is a bug (I think). If the last child has children elements itself, the last-child is not returning true.

ie
<ul>
<li></li>
<li></li>
<li> /*This should be last-child true as it is the last child of the parent, but it is not possibly due to it having children of its own*/
<ul>
<li></li>
<li></li>
</ul>
</li>
</ul>
Please Register to participate.

Active Forums 4.1
     
      
Powered by: Snapsis Software