Forum

Thread tagged as: Question

Blog and standard perch procedures like perch_pages_breadcrumbs()

Hi Perch,

Is there a special way to call procedures like perch_pages_title(); or perch_pages_breadcrumbs(); from my blog/index.php or my post.php? Currently it isn't displaying anything at all and I can't figure out why - it's ok on my other pages - though I do have a similar problem on some pages in the events app.

Thanks

Jane Turnbull

Jane Turnbull 0 points

  • 5 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Yes, there's nothing special about those pages - you should be able to call any page function from any page.

Hi Drew. Thanks for the response. I've narrowed down whats happening. It's nothing to do with apps.

  1. Create standard new top level page.
<?php include('admin/runtime.php'); ?>  
<?php require('inc/global-header.php') ?>

<body>

    <div class="container" id="default_page">
        <div class="row">
            <div class="col-lg-12">
        <?php 
            perch_pages_breadcrumbs(); 
        ?>
            </div>
        </div>
    </div>

    <?php require('inc/global-footer.php') ?>

</body>

</html>

No breadcrumbs are output.

  1. Add in a perch_content for - say - a page header text field before the breadcrumbs. Add some text in header via admin.
    <div class="container" id="default_page">
        <div class="row">
            <div class="col-lg-12">
                <?php perch_content('Page Header'); ?>
        <?php 
            perch_pages_breadcrumbs(); 
        ?>
            </div>
        </div>
    </div>

Breadcrumbs appear nicely after the header as expected.

If I then remove the header, the breadcrumbs are still visible.

So - when I create a brand new page, unless I add a perch content before my breadcrumbs, I can't get them to appear. I think I'm getting the same behaviour with perch_pages_title();, but I need to test that one out again to make sure.

Am I not initialising something?

so - because my blog index doesn't call any perch_content, and just calls perch blog functions to list out posts, the breadcrumbs aren't being displayed. But if I add in any old perch_content call anywhere in the code, and give it a type via the admin, then the breadcrumbs display. The thing is, I don't want any perch_content calls in my blog/index.php page....

Drew McLellan

Drew McLellan 2638 points
Perch Support

You just need to add your blog page so it appears in the Pages list.

Click on Add New Page and then choose the "file already exists" option.

That's already all set up. My blog page is already in the Pages list setup with "file already exists". The only thing to prompt things to work is to add the perch_content and assign a template to that content.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Have you hidden the page from navigation or anything like that?

No. It's all just simply setup. I have Blog in the admin with nothing assigned to it as it's a link only.

If I then add the perch_content and assign a standard text template, I get a new additional blog page in the admin which can then be data filled, but then it all works.

Drew McLellan

Drew McLellan 2638 points
Perch Support

new additional blog page

Ah ha - sounds like the one you added didn't have the correct path.

It should be something like:

 /blog/index.php

Great - thanks You're right - the path was wrong! It has fixed the blog index page.

So - how do I provide some sort of breadcrumb at the post.php/archive.php level (or the events level for the calendar), as I don't want to be creating dummy admin pages for those pages as they would be hidden?

Thanks again for all your help with this.

ok. I see I need to add specifics to post and event pages to handle them differently (as they're not added as a page).

I added the following to get the breadcrumbs on the blog posts:

<a href="/">Home</a> &gt; <a href="/blog">Blog</a> &gt; <?php perch_blog_post_field(perch_get('s'), 'postTitle'); ?>

Thanks again for all your help.

Drew McLellan

Drew McLellan 2638 points
Perch Support

That should do it!

it's not as dynamic as I'd like it to be - but I'm working on it.