Single page controller location

Permalink
Hi all

I'm created a single page and I'd like to use its controller to add some extra javascript to the header. Simple enough.

The single page is located at single_pages/news-and-diary/calendar.php, and the controller is located at /controllers/news-and-diary/calendar/controller.php.

The controller looks like this just now:

<?php
   defined('C5_EXECUTE') or die("Access Denied.");
   class CalendarController extends Controller {
      public function view() {
         $this->addHeaderItem('<script type="text/javascript">console.log("o hai!");</script>');
      }
   }


...but it never fires. The Calendar single page is successfully added to the CMS, and I can browse to it, but no dice on the controller.

I've tried putting the single page at /single_pages/news-and-diary/calendar/view.php, and I've changed the view() function to on_page_view() and on_start() but to no avail.

No doubt it's something stupid but I'm tearing my hair out trying to work out what it is.

melat0nin
 
melat0nin replied on at Permalink Reply
melat0nin
Never mind, silly me didn't include the full path of the controller in its class declaration.

So

class CalendarController extends Controller {


should have been

class NewsAndDiaryCalendarController extends Controller {