Controller + Single_page = No Go
PermalinkI've just picked up Concrete5 as my CMS/Framework of choice but there are still some concepts I can't really grok.
I now that some other people have asked quite the same question before but the error message I get seems to be a different response than what they got.
So I have a view and its controller:
1. application/single_pages/products.php
2. application/controllers/single_page/products.php
Their respective code is:
<?php namespace Application\Controller\SinglePage; use \Concrete\Core\Controller\Controller; class Products extends Controller { public function view() { $this->set('foo', 'bar'); } }
and
I believe the namespacing in the controller page is fine but it seems that the view() method (or whatever other methods I tried) aren't. I get the following error:
Call to undefined method Application\Controller\SinglePage\Products::setupRequestActionAndParameters()
Do you folks have any clues about what going on here? I've spent a few hours already on the docs and the forum and I'm getting nowhere.
Help much appreciated, thanks!
If so, have you tried refreshing the page there?
I experimented further by adding and removing thing and I now know the controller fires.
The issue rather lies in the class definition. Am I missing something in the line:
class Products extends Controller
?
Thanks community
<?php namespace Application\Controller\SinglePage; use \Concrete\Core\Controller\Controller; class Products extends Controller { function on_start() { echo 'started!'; } }
What triggers the error is the view() method. Am I supposed to reference a core View method and then use it? I've never seen an example where it was made so.
I am still stuck.
Thank you
So to make sure your single page and its controller work in C57, you'll need to have something along the following lines:
Controller:
<?php namespace Application\Controller\SinglePage; use \Concrete\Core\Page\Controller\PageController; class Products extends PageController { public function on_start() { echo 'Products Controller started.'; } public function view() { $status = 'started'; $this->set('status', $status); } }
Single Page:
Thank you very much Hewitt. Keep up the good (community) work!
I know very little when it comes to single pages/dashboards in 5.7.