Autonav: get subpages for specific Parent + INCLUDE parent in nav

Permalink 1 user found helpful
How can I get the subpages of a certain page AND that certain page itself to be included in an AutoNav?

I am using this currently, which DOES get the subpages of cID '116' but it doesn't actually include 116 itself in the menu:
$bt_main =BlockType::getByHandle('autonav');
    $bt_main->controller->displayPages = 'custom'; //need to get subpages of Members Area CID
    $bt_main->controller->orderBy ='display_asc';
    $bt_main->controller->displaySubPages ='none';
      $bt_main->controller->displayPagesCID = '116'; //Members Area CID
    $bt_main->render('templates/header_menu');

Since cID '116' is the "Members Home" link, it's an important link.

View Replies:
zoinks replied on at Permalink Reply
A hard-code solution would be great, but in the meantime, I solved my particular problem by creating a blank page and using Mnkras lovely page redirect and page_selector_attribute Add-Ons. Thanks, Mnkras!
Mnkras replied on at Permalink Reply
Mnkras
W00t ;)

Don't forget to leave a good review :P
zoinks replied on at Permalink Reply
Ah, okay, will do that right now.
jordanlev replied on at Permalink Reply
jordanlev
Another solution is to create a custom autonav template and manually ouptut a link to the top level page before the code starts outputting the sub-pages. If you go this route, I would recommend using this autonav template I made which is functionally the same as the built-in one but a million times easier to customize:

https://raw.github.com/jordanlev/c5_clean_block_templates/master/aut...
zoinks replied on at Permalink Reply
link seems to be broken. nothing is loading.
jordanlev replied on at Permalink Reply
jordanlev
EDIT: Link is fixed now.
jordanlev replied on at Permalink Reply
jordanlev
[removed by author]
zoinks replied on at Permalink Reply
Thanks, got it. I already painstakingly created a Custom Template. It sucks that this can't be a separate issue built-into the Autonav block itself, rather than a template fix.

Another issue I've run into with these autonav blocks is that without hardcoding, if you want to display subpages, you have to display subpages for all the Parents.

I think we need a resident genius (ahem) to redesign the whole freaking thing. Thanks in advance ;)
jordanlev replied on at Permalink Reply
jordanlev
I do plan to submit a core patch that integrates this all-encompassing custom template as the new default (just have a lot of things on the todo list ahead of that).

I'm not sure what you mean about "you have to display subpages for all the parents" -- can you please clarify?
zoinks replied on at Permalink Reply
Sure.

I have a top navigation bar. In that bar is a BLOG and a PORTFOLIO.

The PORTFOLIO has 4 sections, so I would like those 4 dropdowns. So, I select 1 level of dropdowns from the autonav options.

Unfortunately, that means BLOG now is going to show all the blog posts under the BLOG Parent page. This is just the default "blog" that comes installed with C5's sample content.
jordanlev replied on at Permalink Reply
jordanlev
In both the template I linked to and the Autonav Exclude Subpages addon, there is functionality for a "Exclude Subpages From Nav" attribute (you have to install this attribute yourself for the template I linked to above, but the addon will automatically install it -- this was what the bug you just reported was related to). Set this attribute on your BLOG page and all of its sub-pages will be excluded from the nav menu.
zoinks replied on at Permalink Reply
Nope. I applied it to the Blog page. Posts still showed up.
zoinks replied on at Permalink Reply 5 Attachments
Attached are several screenshots:

1. FTP showing the package is installed
2. Functionality page showing the package is installed
3. Sitemap showing the Attribute is applied
4. website, showing the blogposts still show up
5. Autonav preferences (Sub-Page Levels Custom: 1)

Perhaps it works for some types of autonav setups, but it isn't working for Sub-Page Levels Custom: 1
jordanlev replied on at Permalink Reply
jordanlev
Did you apply the custom template to that autonav block?
zoinks replied on at Permalink Reply 1 Attachment
Well, at first I applied the custom template and the menu was thoroughly f'ed up. Not even dropdowns, just a bunch of links about 2 inches wide and 3 inches tall. A total mess. See attached image for visual.

So, then I rethought it and thought it probably wasn't necessary based on the Page Redirect and Page Redirect To Newest Child packages which I just recently used simply by installing and adding the attribute via Permissions.

So, this sucks. I have to now try to figure out how the custom template works in order to redesign my menu? I'm surprised it doesn't even show up as dropdowns at all when I choose this
jordanlev replied on at Permalink Reply
jordanlev
Well that is very bizarre because the "Exclude Subpages" template creates the exact same output as the built-in autonav default template. Perhaps you were using a different custom template on the autonav before to make it work as a dropdown?

If you need to style it, I highly recommend using the template I linked to above (not the Exclude Subpages addon) because it was made to be customized -- it's really easy to figure out and work with, whereas the Exclude Autonav addon template is mostly the same as the built in template which is not very easy to work with at all.

All three should give you the same exact html output though if you haven't customized anything.
zoinks replied on at Permalink Reply
I took a look at your template and there are a lot of comments. I have no idea what is optional and what is mandatory. I especially don't understand what I'm supposed to do under the "customize the HTML starting here" comment since all I would expect to do is style a UL via CSS.
jordanlev replied on at Permalink Reply
jordanlev
Perhaps I've misunderstood your use case. If all you want to do is modify the CSS, then you don't need a custom template at all -- you can just put different CSS in your theme's stylesheet. The template I linked to above is for when you want to do things like change the html structure of the menu (if you didn't want an unordered list, for example), or if you need to insert other elements into the list (like <span> tags for example). Also if you want to include different or additional css classes in each list item (beyond just the "nav-selected" and "nav-path-selected" ones that C5 includes).
zoinks replied on at Permalink Reply
No, you understood me just fine. It seems I just don't understand your template, unfortunately.
jordanlev replied on at Permalink Reply
jordanlev
Well, it's really ideal for when you already have a menu in HTML/CSS, and you need to implement that as a C5 menu. If you're just trying to change your C5 menu on-the-fly to some unspecified "different" thing, yeah it's going to be confusing.
zoinks replied on at Permalink Reply
I do already have an HTML/CSS menu and I'm not trying to change it to anything unspecific. I'm trying to keep it the same and just remove the subpages from the Blog parent.

Thanks for your help, I don't want you to waste any more of your time trying to explain this to me. I don't think it will do any good. But, I appreciate that you took a lot of trouble to try.
zoinks replied on at Permalink Reply
Jordan,

Do I just uncomment this bit in the view.php if I want to apply the exclude submenu attribute?

/*
if (!empty($ni->attribute_class)) {
//class that can be set by end-user via the 'nav_item_class' custom page attribute
$classes[] = $attribute_class;
}
*/
jordanlev replied on at Permalink Reply
jordanlev
Yes (so delete the "/*" above and the "*/" below). You will also need to create a page attribute of the "textbox" type (or maybe it's just "text"?) with the handle "nav_item_class" (the attribute name can be whatever you want).
zoinks replied on at Permalink Reply
Okay, I created that text attribute... but what do I do with it? Do I add it to a page or something?

Somehow, I managed to get that view.php to mostly work, but can you please explain to me WHAT in the heck are the strange lines on the top right 2 links of the PORTFOLIO dropdown?

http://lukevalhe.pairserver.com/concrete5.4.2.1/index.php?cID=1...

strange lines of no uniformity!
jordanlev replied on at Permalink Reply
jordanlev
It looks good to me -- Chrome and FF on Windows XP.
I don't see weird lines above PORTFOLIO. And it's hard to tell if the nav menu structure is being outputted correctly because you have the page compressed with MISER. I would turn off MISER to see if that fixes anything (that thing is amazingly awesome but also causes a *lot* of incompatibilities that need to be slogged through, in my experience). Also post back after it's off so I can see the page source uncompressed. (Probably can't respond again until tomorrow though, I'm stepping away from the computer for the evening now).

EDIT: BTW, you can temporarily disable MISER without having to remove files and such by adding this line to your config/site.php file:
define('MISER_ENABLE', FALSE);
zoinks replied on at Permalink Reply 1 Attachment
WEIRD LINES - see attached

The are not above portfolio, they are at the top right of the portfolio dropdown underneath the words "Parke Ave" (misspelled) and "Rustic Modern."
jordanlev replied on at Permalink Reply
jordanlev
Sorry, didn't answer you first question -- for the text attribute, you create it in Dashboard -> Pages and Themes -> Attributes.
Then once it's created, you would set it on a page, just like any other page attribute (if the page already exists, go into edit mode on that page, click "Properties" in the toolbar, click "Custom Attributes" tab, choose that attribute from the "**" dropdown, enter the class name you want in the textbox).
zoinks replied on at Permalink Reply
I have created the attribute. I didn't put it on the page. Doesn't really seem like I need to. What is it supposed to do?
jordanlev replied on at Permalink Reply
jordanlev
Jeez, sorry about this -- I just scrolled back up and re-read your original question about the un-commenting. I was getting confused between this and another thread where someone was asking about that. So... actually you don't need that text attribute at all (and you can re-comment that code you were asking about above -- it's for something else entirely).
For the excluding of a sub-pages, what you need to do is create a "checkbox" attribute with the handle "exclude_subpages_from_nav". Then if you check that attribute on a page, the template will automatically exclude its children pages from the nav menu.
zoinks replied on at Permalink Reply
There were two questions kind of mashed up. You helped me A LOT. I uncommented nav-selected and used this in my view.css to style the dropdowns and 3rd tier flyout dropdowns. I don't think I did it how I was SUPPOSED to because I just uncommented that one bit on your view.php and then modified my already working dropdown CSS from a previous incarnation of the menu to match your classes. This involved a search and replace of .menu for .nav and changing stuff like ".nav ul ul :hover li" to something like ".nav-selected ul :hover li" (or whatever). Took about 45 minutes to figure out and I learned a lot.

I will be using your view.php in the future for sure, even though I don't really understand all the options on it, so thank you very much!
msucal replied on at Permalink Reply
We spent hours on this and this is the CLEAR answer:

http://www.concrete5.org/community/forums/chat/auto-nav-question/...

Just look at the attachment