Forum

Thread tagged as: Addons, Add-on-development

Outputting the category name on the Archive page of the Events App

Hi there

Apologies my knowledge of PHP is very weak. What I'm trying to do for the archive.php page (using the Events app) is simply output the category within the H1 tag.

For example: https://www.lovebedfordoffers.co.uk.gridhosted.co.uk/offers/archive.php?cat=entertainment

I'm trying to get it to say 'Entertainment Offers'

The code I'm using is:

  <?php
/* --------------------------- POSTS BY CATEGORY --------------------------- */
if (perch_get('cat')) {
    echo '<h1>'.perch_events_custom(perch_get('cat'), true).' Offers</h1>';


}



?>
Rich Hemery

Rich Hemery 0 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

You need perch_events_category()

if (perch_get('cat')) {
    echo '<h1>'.perch_events_category(perch_get('cat'), array(), true).' Offers</h1>';
}

Thanks Drew, got it working. For some reason though it's adding H1 tags automatically, the code I've got is:

 if (perch_get('cat')) {
echo ''.perch_events_category(perch_get('cat'), array(), true).'';

}

which is working fine on: https://www.lovebedfordoffers.co.uk.gridhosted.co.uk/offers/archive.php?cat=accommodation

However, now I've come to edit the TITLE with the following code:

 <title>Love Bedford Offers · <?php perch_events_category(perch_get('cat'), 'cat'); ?></title>

And you can see the <h1> tags are appearing in the Browser title.

Drew McLellan

Drew McLellan 2638 points
Perch Support

That will be from the default template.

perch_events_category(perch_get('cat'), array(
    'template' => 'your_template.html',
));

Hi - where do I find the default template so I can remove the <h1> tags?

Drew McLellan

Drew McLellan 2638 points
Perch Support

/perch/apps/perch_events/templates/events

https://docs.grabaperch.com/addons/events/template-tags/