Forum

Thread tagged as: Error, Events

'return-html' not implemented in 'perch_events_custom'

The option is spec'd here https://docs.grabaperch.com/addons/events/page-functions/custom/, but is not implemented in the latest version of the app (as far as I can tell).

To resolve this, made the following changes to PerchEvents_Events.class.php.

Old Code (starting line 387)

        if (isset($opts['skip-template']) && $opts['skip-template']==true) {

            if ($single_mode) return $Event;

            $out = array();
            if (PerchUtil::count($events)) {
                foreach($events as $Event) {
                    $out[] = $Event->to_array();
                }
            }
            return $out; 
        }


        // template
        if (isset($opts['template'])) {
            $template = 'events/'.str_replace('events/', '', $opts['template']);
        }else{
            $template = 'events/event.html';
        }

        $Template = $this->api->get("Template");
        $Template->set($template, 'events');

        if (PerchUtil::count($events)) {
            $html = $Template->render_group($events, true);
        }else{
            $Template->use_noresults();
            $html = $Template->render(array());
        }

New Code

       // template
        if (isset($opts['template'])) {
            $template = 'events/'.str_replace('events/', '', $opts['template']);
        }else{
            $template = 'events/event.html';
        }

        $Template = $this->api->get("Template");
        $Template->set($template, 'events');

        if (PerchUtil::count($events)) {
            $html = $Template->render_group($events, true);
        }else{
            $Template->use_noresults();
            $html = $Template->render(array());
        }

        if (isset($opts['skip-template']) && $opts['skip-template']==true) {

            if ($single_mode) return $Event;

            $out = array();
            if (PerchUtil::count($events)) {
                foreach($events as $Event) {
                    $out[] = $Event->to_array();
                }
            }

            if (isset($opts['return-html'])&& $opts['return-html']==true) $out['html'] = $html;

            return $out; 
        }
Richard Kimber

Richard Kimber 0 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

The Events app predates that feature.

Hi Drew. Might be worth updating the documentation if you're not going to support the feature. Rich

Drew McLellan

Drew McLellan 2638 points
Perch Support

We are going to support the feature. That table is a common feature - it's not specific to that one app.

Okay, I'll leave you to it. I just think the documentation is very misleading, if the feature isn't supported. Rich

Thanks Richard for your fix. I agree, the documentation should reflect the current implementation, not the future plan for implementation.