Single page controller at directory root
Permalink
I have created a package with several single pages. Some of the pages are sub-pages of others. The sub-page controllers are working just fine, but the controllers in the root folders are not.
My sitemap looks like this:
Home
- Employer
- - Jobs
Both "Employer" and "Jobs" are added by the package. I can add variables to the view() function of the Jobs controller and print it on the Jobs page.
However, the Employer controller is not passing any variable through the view() function.
In the package controller, I am adding the pages like this:
In the package, the files are arranged like this:
[package-root]/controllers/single_page/employer/controller.php
[package-root]/controllers/single_page/employer/jobs.php
[package-root]/single_pages/employer/view.php
[package-root]/single_pages/employer/jobs.php
The namespace and class for the Employer controller ([package-root]/controllers/single_page/employer/controller.php):
The namespace and class for the Jobs controller ([package-root]/controllers/single_page/employer/jobs.php):
The "test" variable works on the Jobs page, but not on the Employer page. Any ideas on why this is and how to fix it?
My sitemap looks like this:
Home
- Employer
- - Jobs
Both "Employer" and "Jobs" are added by the package. I can add variables to the view() function of the Jobs controller and print it on the Jobs page.
However, the Employer controller is not passing any variable through the view() function.
In the package controller, I am adding the pages like this:
$pgEmployer = SinglePage::add('/employer', $pkg); $pgJobs = SinglePage::add('/employer/jobs', $pkg);
In the package, the files are arranged like this:
[package-root]/controllers/single_page/employer/controller.php
[package-root]/controllers/single_page/employer/jobs.php
[package-root]/single_pages/employer/view.php
[package-root]/single_pages/employer/jobs.php
The namespace and class for the Employer controller ([package-root]/controllers/single_page/employer/controller.php):
namespace Concrete\Package\JobPostings\Controller\SinglePage; class Employer extends PageController { public function view() { $this->set('test','The controller is connected.'); } }
The namespace and class for the Jobs controller ([package-root]/controllers/single_page/employer/jobs.php):
namespace Concrete\Package\JobPostings\Controller\SinglePage\Employer; class Jobs extends PageController { public function view() { $this->set('test','The controller is connected.'); } }
The "test" variable works on the Jobs page, but not on the Employer page. Any ideas on why this is and how to fix it?
Thanks linuxoid and also to CRA via Slack! I have this working.
I need to move the Employer controller while leaving the view.php file in place. Here is a working example:
[package-root]/controllers/single_page/employer.php
[package-root]/single_pages/employer/view.php
I need to move the Employer controller while leaving the view.php file in place. Here is a working example:
[package-root]/controllers/single_page/employer.php
namespace Concrete\Package\JobPostings\Controller\SinglePage; class Employer extends PageController { public function view() { $this->set('test','The controller is connected.'); } }
[package-root]/single_pages/employer/view.php
[package-root]/controllers/single_page/employer.php
[package-root]/single_pages/employer.php