Odd... it's not working for some reason on this website.

Permalink Browser Info Environment
Any idea what might make it not work?

Type: Discussion
Status: New
View Replies:
zoinks replied on at Permalink Reply
I had to download your view.php from GitHub and put it in root/blocks/autonav/ for some reason. I thought that your view template would be included and functioning in the package installation.

It's working now, did I do something wrong? Or do I always need to grab that view.php and stick it in there. Just want to make notes for next time so I don't struggle again and waste time.

Thanks!
jordanlev replied on at Permalink Reply
jordanlev
Uhh... kind of hard to say without any details :)

Did you install the package? Did you choose the "Exclude Subpages" custom template for your autonav block?
zoinks replied on at Permalink Reply
No I didn't choose "exclude subpages" template because I didn't realize that was necessary. I thought you just had to add the attribute in "properties" to the Parent page.

Oddly, as I explained above, once I downloaded that view.php of yours from Github and uploaded it to root/autonav, it worked fine.

If that's not how it's supposed to work, then check it out. Cuz it works! I have multiple templates with a hard-coded left menu and no custom template is applied to any of those menus. I only selected the "exclude subpages" attribute in the properties panel on the Parent page. This is the second website where I've done it this way. :)
jordanlev replied on at Permalink Reply
jordanlev
So the way block templates work in C5 is this: every block has a default template, which is the 'view.php' file. If you just add a block, it always uses that template. You can override that template by creating a top-level folder for the block and putting your own view.php file in there (for example, SITEROOT/blocks/autonav/view.php) -- and C5 will automatically use that instead of the built-in view.php file. When you downloaded the template I have on github, I'm assuming you just called it "view.php" and put it in that /blocks/autonav/ directory -- so C5 sees that's there and uses it without any further work required on your part.

But custom templates are in a sub-folder of the block called "templates", and have different names (other than "view.php" -- although confusingly, there could be a file called "view.php" for a custom template but it would itself be inside another sub-folder that had the template name in it). This is how the "Autonav Exclude SubPages" addon works -- it's a different template file with a different name, so C5 does not automatically use it, and instead you must choose it as the custom template in order for it to take effect.

My reasoning behind making the addon a different custom template that you must choose is so that it's less invasive to your site when you install it -- I understand that it can be confusing when you install it and nothing happens out-of-the-box, but I feel this is a lesser evil than installing it and now seeing your nav menu change in an unexpected way, and having no way to change it back to the default template.
On the other had, the template I have on github is a bit more complicated to use because you have to know what github is and know how to create your own code files, so it's really for designers and developers, not end-users.

Hope that clears things up.

-Jordan
zoinks replied on at Permalink Reply 1 Attachment
Ah, cool! Well, I'm glad it works just by substituting the main autonav view.php because it would be a real p.i.t.a. to put a custom template on 5 different pages. I'm not sure how your view.php really works, but it seems to clearly be superior because I've noticed some other nav issues I struggled with in the past were magically working right away on the last few sites, such as nav-select and nav-path-select when working with show/hide submenus like the attached jpeg.
jordanlev replied on at Permalink Reply
jordanlev
Honestly, if you know how to download the file from github and put it into your site, that's going to be a better option -- it includes everything in the "Exclude Subpages" addon, plus it's way easier to customize the template if needed.
But if you did want to use the "Exclude Subpages" addon for some reason, you could copy the file "SITEROOT/packages/autonav_exclude_subpages/blocks/autonav/templates/exclude_subpages.php" to "SITEROOT/blocks/autonav/templates/view.php" and then it would override your built-in autonav template thus not requiring you to choose it as a custom template.
stuball replied on at Permalink Reply
stuball
This was unclear to me as well (that I had to go to the Autonav block in question and choose this custom template from there). Now I know where to look. Perhaps a few extra words in the main page might help others?

Thank you for this most helpful add-on!
jordanlev replied on at Permalink Reply
jordanlev
The 2nd paragraph says this:

----
To use this custom template, simply edit a page that has an autonav block, click on the autonav block, choose "Custom Template" from the popup menu, then choose "Exclude Subpages" from the dropdown list and click the "Update" button.
----

But I know what makes sense to me doesn't always make sense to everyone else. If you have a suggestion for how it could be worded better or made more prominent, I'd be happy to hear it.

-Jordan
pakigreenl replied on at Permalink Reply
pakigreenl
How do I do that for a hardcoded Nav? here is the code for the nav:

<?php  
            $bt_main = BlockType::getByHandle('autonav');
            $bt_main->controller->displayPages = 'top';
            $bt_main->controller->orderBy = 'display_asc';                    
            $bt_main->controller->displaySubPages = 'all';
            $bt_main->controller->displaySubPageLevels = 'custom';      
            $bt_main->controller->displaySubPageLevelsNum = '1'; 
            $bt_main->render('templates/dropdown');
         ?>
pakigreenl replied on at Permalink Reply
pakigreenl
Got it. Just changed "dropdown" to "exclude_subpages"
<?php  
            $bt_main = BlockType::getByHandle('autonav');
            $bt_main->controller->displayPages = 'top';
            $bt_main->controller->orderBy = 'display_asc';                    
            $bt_main->controller->displaySubPages = 'all';
            $bt_main->controller->displaySubPageLevels = 'custom';      
            $bt_main->controller->displaySubPageLevelsNum = '1'; 
            $bt_main->render('templates/dropdown');
         ?>

concrete5 Environment Information

Browser User-Agent String

Hide Post Content

This will replace the post content with the message: "Content has been removed by an Administrator"

Hide Content

Request Refund

You have not specified a license for this support ticket. You must have a valid license assigned to a support ticket to request a refund.