Forum
Adding blog posts into perch navigation structure
Hi there,
I am using perch_pages_navigation to output my website's navigtion. I have two different blog sections that I would like to add into the navigation structure.
So far I have set up my blog sections ('Newsfeed' and 'School notices'), added a top level parent page 'News', and moved the blog section folders into that parent page folder. I have added a link to the sections from the admin panel using 'This page already exists or is a link only'.
For every top level page I output the children pages as cards using:
<?php perch_pages_navigation(array(
'levels' => 1,
'from-path' => '*',
'template' => 'section.html',
)); ?>
'Newsfeed' and 'School notices' show up here and clicking on them leads to their respective feeds. So far so good. My problem is, that on the feed pages as well as on the individual posts in both sections, the .parent class is not added to either the top level parent page or the respective section page. In short, my navigation structure is 'News > Newsfeed > {Newsfeed post}' and 'News > School notices > {School notices post}'. The URL for a post is /news/newsfeed/post.php?s={slug}.
How do I add the blog sections into the perch navigation structure properly?
PS: My diagnostics report:
Perch: 2.8.13, PHP: 5.6.7, MySQL: mysqlnd 5.0.11-dev - 20120503 - $Id: 3c688b6bbc30d36af3ac34fdd4b7b5b787fe5555 $, with PDO
Server OS: Darwin, apache2handler
Installed apps: content (2.8.13), assets (2.8.13), categories (2.8.13), perch_blog (4.6), perch_forms (1.8.3), perch_gallery (2.8.6), perch_mailchimp (2.0.1)
App runtimes: <?php $apps_list = array( 'content', 'categories', 'perch_blog', 'perch_gallery', 'perch_forms', 'perch_mailchimp' ); ?>
Does the post page exist as part of the navigation structure?
What exactly do you mean by that? The individual post pages don't, since I don't want to add them all individually, that's something that should happen automatically.
I added the newsfeed (i.e. the list of posts) through the perch admin panel by adding it as a page that already exists. It shows up in the navigation bar, but when I navigate to it, the .parent and .selected classes aren't being added to the navigation bar.
I mean have you added your post page (like
post.php
in the example files) to the Pages section?Oh, you mean into the folder on the server? Yes, all of the example files are in the 'Newsfeed' as well as in the 'School notices' folder, some of them are modified.
No, I mean in the Pages list within Perch. You added blog as a page - have you also added the post page?
I don't quite understand what you mean by post page. As in /news/newsfeed/post.php?s={slug} ?
This is my index file for news/newsfeed/ :
I have linked to this index file in my Pages list within Perch. In the same folder are the 'post.php' and other example files.
Ignoring what I have done so far, what would be the proper way to add the two blog sections into the Perch navigation structure?
You said this, which is great:
Now do the same for the
post.php
page, and check the 'hide from navigation' option.Ah, so I just add the general page! Makes sense. Works like a charm now! Thank you so much! I've been going crazy over this for a while.