Forum

Thread tagged as: Question, Problem, Addons

Templates for archive.php

Sorry, this is probably a really stupid question but I can't seem to find the answer. I'm trying to change how the archive.php listings are presented and I can't seem to find any of the templates that control them.

I'm looking for the templates that control these listings, I honestly can't find them at all.

/* --------------------------- POSTS BY CATEGORY --------------------------- */
                        if (perch_get('cat')) {
                            echo '<h1>Archive of: '.perch_blog_category(perch_get('cat'), true).'</h1>';

                            perch_blog_custom(array(
                                    'category'   => perch_get('cat'),
                                    'template'   => $template,
                                    'count'      => $posts_per_page,
                                    'sort'       => $sort_by,
                                    'sort-order' => $sort_order,
                                    ));

                            $posts_displayed = true;
                        }


                        /* --------------------------- POSTS BY TAG --------------------------- */
                        if (perch_get('tag')) {
                            echo '<h1>Archive of: '.perch_blog_tag(perch_get('tag'), true).'</h1>';

                            perch_blog_custom(array(
                                    'tag'        => perch_get('tag'),
                                    'template'   => $template,
                                    'count'      => $posts_per_page,
                                    'sort'       => $sort_by,
                                    'sort-order' => $sort_order,
                                    ));

                            $posts_displayed = true;
                        }

Can anyone point me in the right direction please?

Thank you.

Cameron Duthie

Cameron Duthie 0 points

  • 4 years ago
Rachel Andrew

Rachel Andrew 394 points
Perch Support

If you turn on debug then you will see an output of which template is being used for any content https://docs.grabaperch.com/perch/configuration/debug/

Thanks Rachel, is there a way to output that on a live site?

Rachel Andrew

Rachel Andrew 394 points
Perch Support

Presumably you aren't working directly on a live site, I wouldn't advise it anyway.

I'm working in a live environment not visible to the public. Would you be able to point me in the right direction for the above default templates? I'm still struggling to find them. Thanks for your help Rachel.

Rachel Andrew

Rachel Andrew 394 points
Perch Support

If it isn't visible to the public, enable debug and you'll be able to see. I don't know how your site is set up.

Thanks Rachel.

I don't think I'm being very clear here. I'm trying to change the way posts are displayed in the archive.php. At the moment it's pulling in default templates. Currently this is the page > https://www.orchidaberdeen.com/blog/archive.php

I would like to add the listing image and remove the comments section for post listing that appears under "archive". I would like to edit the default template it's using to pull this information from but I can't seem to find it anywhere.

Would you be able to point me in the right direction please?

Thanks again for your help.

Duncan Revell

Duncan Revell 78 points
Registered Developer

If you turn on debug for that archive.php page, as Rachel suggests, it will tell you exactly which template is being used and exactly where the template is.

Hi Duncan, thanks for the response. I've turned on debug however, I can't view archive.php in the admin so I can't see where the template is? I get this is probably me being really stupid but I'm struggling here.

Duncan Revell

Duncan Revell 78 points
Registered Developer

Did you also add

<?php PerchUtil::output_debug(); ?>

to the archive.php page? Once you have done so, view the page live (https://www.orchidaberdeen.com/blog/archive.php) and you will see all the debug info at the bottom of the page.

Invaluable for any Perch work.

Hi David,

I added that right under the perch include and there isn't anything at the bottom of the page of the live page.

<?php include('../perch/runtime.php'); ?>
<?php PerchUtil::output_debug(); ?>

The debug is appearing in admin but not on the live page, nothing is showing up in the inspector tools either. :(

Any ideas on why that might not be working?

Rachel Andrew

Rachel Andrew 394 points
Perch Support

It needs to be at the bottom of your page, or in a footer include. It won't have anything to output if no processing has yet been done.

Perfect, thanks guys! That's got it working!

Thanks for all the help you two, much appreciated. :)