Menu under external link

Permalink
I have a site that needs a menu structure like:

Page 1
Page 2
Placeholder
    Page 3
    Page 4
Page 5


Placeholder doesn't need to be an actual page, just an empty menu item to act as a title for the submenu. I used an external link pointing to "#" and was able to move pages underneath it in the sitemap. This works correctly--as long as I'm logged in. When viewing the site normally (logged out) however, the submenu items don't show up. That <ul> tag isn't being generated. Any ideas?

Using Concrete 5.5.1.

chemmett
 
ConcreteOwl replied on at Permalink Reply
ConcreteOwl
Check the permissions on the sub pages are allowing "guests" to read them
chemmett replied on at Permalink Reply
chemmett
Thanks for the reply. I did check that... permissions are correct and I can access the subpages by typing in the URL. And if I create a real page as the placeholder and put the sub-pages under it, everything works fine. But then users and search engines get confused by a blank page, thus my reasoning for trying to use an empty external link.

It's just putting pages under an external link that's not working for non-logged-in users.
ConcreteOwl replied on at Permalink Reply
ConcreteOwl
Have you checked in the page properties that exclude from nav is not selected?
chemmett replied on at Permalink Reply
chemmett
Yeah, page properties were fine. Like I said, if I put the sub-pages under a normal page, they work as expected, but if they're under an external link, they don't.

Ended up using the "Page Auto-Redirect" add-on to redirect the empty top-level page to the first sub-page. Not exactly the way I'd wanted to do it, but it works.
tsilbermann replied on at Permalink Reply
tsilbermann
Same Problem here (5.6.0.2). This solution seams not to work. Any other idea to create a placeholder (changing php code in autonav view.php is not working like described in older treads)?

Update:
Got it running - viewing permissions for guests have to set (again).
jordanlev replied on at Permalink Reply
jordanlev
Another solution for 5.6.x is to make a new page attribute, then override the view template to not output a link if a page has that attribute set. For example, you could create a new page attribute of the "checkbox" type, giving it handle "page_link_disabled". Then copy /concrete/blocks/autonav/view.php to /blocks/autonav/view.php, and edit that copy and change this:
echo '<a href="' . $ni->url . '" target="' . $ni->target . '" class="' . $ni->classes . '">' . $ni->name . '</a>';

...to this:
if ($ni->cObj->getAttribute('page_link_disabled')) {
    echo $ni->name;
} else {
    echo '<a href="' . $ni->url . '" target="' . $ni->target . '" class="' . $ni->classes . '">' . $ni->name . '</a>';
}
tsilbermann replied on at Permalink Reply
tsilbermann
Thanks for the tip Jordan.

To let the placeholder work on mobile devices wouldn't it be better to give the placeholder a <a href="#"> link?

That should look like this:

if ($ni->cObj->getAttribute('page_link_disabled')) {
    echo '<a href="#">' . $ni->name . '</a>';
} else {
    echo '<a href="' . $ni->url . '" target="' . $ni->target . '" class="' . $ni->classes . '">' . $ni->name . '</a>';
}


But I think this solution is not search engine friendly. In the URL the placeholder is always visible like:

"mysite.com/about/awards"
should be
"mysite.com/awards"

when "about" is the placeholder.
jordanlev replied on at Permalink Reply
jordanlev
Why won't my solution work for mobile? It's just outputting the name of the page without a link... doesn't have to do with mobile at all.

Your solution is okay as well, if that works better for you (it will probably be easier to fit into your existing menu style because most menus only have styles for <a> tags... perhaps that is the problem you are having with my solution?). But I personally don't prefer it because it makes users think they can click on something but they can't (because when they hover the mouse over it, the cursor will change, and also when they click on it, it will scroll the browser window up to the top of the page).

If the styling is an issue, try wrapping the name in a <span> instead of an <a>, then copy all the styles in your css that apply to the menu <a> links so they also apply to <span>.
vernb replied on at Permalink Reply
vernb
Hi

I had the same problem regarding place holders and I was using the solution here
http://www.concrete5.org/documentation/how-tos/developers/create-me...

But that won't work with the latest version of c5.

I was reasonably happy with using replace_link_with_first_in_nav but as my menu reveals its sub-menus on hover, this was no good with a touch screen. All anyone could get on a touch screen was the first link and none of the other ones on the sub-menu.

My menu uses jquery to produce slidedown and fade effects, plus one or two other extra things I also needed. so I played around with idea within there and came up with this extra bit which removes the click event:

$("#menu li:has(ul)").hover(function () {
     $(this).children("a").click(function () {
        return false;
     });
  });

I keep the replace_link_with_first_in_nav as a fall back.

Hope this is of help... and if anyone uses it and finds any problems with this solution, let me know on this thread.
BirgirGisla replied on at Permalink Reply
This is an old post, but I have been trying to achieve the same thing on my site (I'm new to C5). The original how-to advice (http://www.concrete5.org/documentation/how-tos/developers/create-menu-placeholders-in-the-auto-nav/) does not work with the latest version of C5.

I agree with tsilbermann that the proposed placeholder solution is not SE friendly. So instead of using placeholder pages, I used external page with # as the link. Then moved the relevant pages underneath the external page and re-applied the permissions to all the sub-pages. I then added the following code into the view.php:

if ($ni->url == '#') {
       echo '<span>' . $ni->name .'</span>'; 
   } else {
       echo '<a href="' . $ni->url . '" target="' . $ni->target . '" class="' . $ni->classes . '">' . $ni->name . '</a>';
   }


Basically this checks if the page is an external page, instead of a placeholder, and then does the same as suggested above.

I then modified the css file to handle the "span" element in the same way as "a href" element in the navigation bar. This way you will ensure proper tree structure of your site and the SE spiders don't see the external page when they crawl your site.

Hope this helps someone who is trying to achieve this on their website.