I have run into this weird little issue and want to ask if anyone else has seen it.
I have a built a multilanguage page with the latest release (9.3.8) and the “page_forbidden” single-page template does not seem to receive a $c variable from the controller.
When access a “wrong” page, I get the error message instead of either the original singlepage or any template I place into the singlepage folder. Shouldnt it work out of box?
Or did I manage to mess it up myself and dont know how?
I think it should be available. I just checked a theme that has a custom single page for page_forbidden and although $c is not used on the page, it is used in the included elements and it renders fine.
You might check what is getting passed into the elements when they are being called from the single page context - that might shed some light - I don’t think elements naturally have access to $c because they’re just kinda standalone components that get variables pipe into them for use is my understanding.
Then I created a controller in applications/controllers/offre_detail_controller.php in which I’m using the view by specifying my theme like this
$view = new View('/offre_detail');
$view->setViewTheme('duosante');
$view->setController($this);
$this->set('jobDetail', $jobDetail);
return $this->responseFactory->view($view);
Then I have my view file in application/views/offre_detail.php with my HTML. This HTML is inserted into my theme’s view.php using <?php echo $innerContent;?>
Unfortunately I have lots of problems with the display with the error: Undefined variable $c.
Why is $c not initialized in this configuration? And how to initialize it?
Following this code, it seems you are creating totally custom controller.
So by design, it’s not connected to any “Page”/“Single page” in CMS.
Hence you can’t access $c variable.
Is it for fetch/ajax call? You would need to pass page id in url like: