Unexpected getLevel values in autonav

Permalink
Concrete 5.3.1.1

I've created a couple of custom autonav views to provide a common dropdown nav menu at the top of page and a location-specific popout menu at the side of the page. Both use a test on the item level like

$thisLevel = $ni->getLevel();
  if ($thisLevel > $lastLevel) {


to determine closing A LI and UL tags and so forth; basically a minor revision of concrete/blocks/autonav/view.php

However, I seem to be getting odd values for $ni->getLevel in relation to the position of items in the menu; some of the offending items are single pages; others may have been moved in the sitemap hierarchy. Example - the numbers in square brackets are the level and previous level respectively:

# NCETA[1, 0]
  * About Us[2, 1]
      o Strategic Context[3, 2]
        + Strategic Directions[3, 3]
        + Business Plan[3, 3]
        + Annual Reports[2, 3]
      o Partnerships[2, 2]
      o Board of management[2, 2]
      o Contact Us[2, 2]
      o Staff[1, 2] (single page)
  * Publications[1, 1] (single page)
  * Research & Projects[2, 1]
      o Current Projects & Research[2, 2]
      o Past Projects & Research[0, 2]


This results in extra closing tags in some cases which fouls up the page validation and I suspect may also be causing me some major problems in IE6 with popouts and dropdowns. Surprise :-)

Any ideas where I might look to try and resolve this?

 
ryan replied on at Permalink Reply
ryan
It looks like the level is for the next item in the list, not the current item. So your values are [next item, current item].

Does a normal autonav produce valid html?
ryan replied on at Permalink Reply
ryan
BTW all the logic for the autonav is in /concrete/blocks/autonav/controller.php
robleyd replied on at Permalink Reply
The following code snippet produces the level values in my first post:
$_c = $ni->getCollectionObject();
    /* Exclude any entries marked not for general navigation display, or not for top menu display */
      if (!$_c->getCollectionAttributeValue('exclude_nav') && !$_c->getCollectionAttributeValue('exclude_topNav') ) {
         $thisLevel = $ni->getLevel();
      echo "$thisLevel, $lastLevel";  // Debug echo

Unless I misunderstand what getLevel() returns, that should show the current and previous levels??

Creating a test autonav with no custom template (should then use the default autonav view) returns no HTML errors in the menu block, so I guess I need to revisit my custom view :-(

I'd be interested to know which of the db tables holds the page structure, particularly the item level?

I'm looking into the controller code as well.

Thanks for your response!