Forum

Thread tagged as: Question, Problem

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' ); ?>
Nicolai Davies

Nicolai Davies 0 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Does the post page exist as part of the navigation structure?

Drew McLellan said:

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.

Drew McLellan

Drew McLellan 2638 points
Perch Support

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.

Drew McLellan

Drew McLellan 2638 points
Perch Support

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/ :

<?php include('../../perch/runtime.php'); ?>
<?php perch_layout('header'); ?>
<title>Newsfeed | Waterford Kamhlaba UWCSA</title>
<meta name="description" content="Catch up on the latest news and read captivating stories from Waterford Kamhlaba." />
<?php perch_layout('navigation'); ?>


    <section class="cards">
      <?php perch_blog_custom(array(
        'count' => 7,
        'section' => 'newsfeed',
        'template' => 'post_in_news.html',
        'sort' => 'postDateTime',
        'sort-order' => 'DESC'
      )); ?>
    </section>
<?php perch_layout('footer'); ?>

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?

Drew McLellan

Drew McLellan 2638 points
Perch Support

You said this, which is great:

I have added a link to the sections from the admin panel using 'This page already exists or is a link only'.

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.