Forum

Thread tagged as: Addons, Events

Formatting event category archive.php's content

Is it possible to format the output of the perch_events_category(perch_get('cat')) call, as demonstrated in the example archive.php file that comes in the Events addon download?

I'm customizing the default archive.php, trying to create a category listing page that outputs the content of the category information based on the slug. I see how that perch_events_category routine outputs the information input into the event category in the dashboard section for the addon -- the image and the description text.

The debug information doesn't show any template being included for the content that the routine outputs. Not as far as I can tell. I tried copying the addon's category.html into perch/templates/events/, but it didn't reflect my edits, and the debug information doesn't show category.html.

I suppose I could try calling perch_events_category with an array, and then making my own HTML template to be specified in a 'template' key within the array -- but I would have no idea what kind of perch:events or (other perch tags) to use to get the content I need from the input fields in the dashboard.

Here's what my modified archive.php file looks like at the moment:

<?php include('perch/runtime.php'); ?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>Perch Events Example</title>
    <?php perch_get_css(); ?>
    <link rel="stylesheet" href="css/styles.css" type="text/css" />
</head>

<body>

    <?php
    perch_layout('global.header',array(
      'navparent' => 'events',
            'sublevel' => 'true',
    ));
  ?>

    <?php perch_content('Events Section Title'); ?>

    <div id="main-content-parent">

        <?php
            perch_events_category(perch_get('cat'));
        ?>

        <h2>Upcoming events</h2>

        <?php
            perch_events_custom(array(
                'category'   => perch_get('cat'),
                'filter'     => 'eventDateTime',
                'match'      => 'gte',
                'value'      => date('Y-m-d'),
                'sort'       => 'eventDateTime',
                'sort-order' => 'desc',
                'template'   => 'listing/custom-listing-day.html'
         ));
        ?>

        <h2>Past events</h2>

        <?php
                perch_events_custom(array(
                    'category'   => perch_get('cat'),
                    'filter'     => 'eventDateTime',
                    'match'      => 'lt',
                    'value'      => date('Y-m-d'),
                    'sort'       => 'eventDateTime',
                    'sort-order' => 'desc',
                    'template'   => 'listing/custom-listing-day.html'
        ));
        ?>

        <nav class="sidebar">
            <!--  By category listing -->
            <?php perch_events_categories(); ?>
        </nav>


    </div>

    <?php perch_layout('global.footer'); ?>

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

    <?php perch_get_javascript(); ?>
</body>
</html>
Paul Lee

Paul Lee 0 points

  • 4 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

It uses category.html but it's also cached, so make sure you switch your PERCH_PRODUCTION_MODE flag to PERCH_DEVELOPMENT.

Yes, that was the reason.