5.7 Single Pages controller

Can anyone give me an example of how to setup a single page in both the single page directory and in the controller directory so that the single page can pull information from the controller?

I did a quick and dirty version of my app just to see what c5 is all about and it worked out pretty well. I'm now re-factoring the whole thing MVC (I did my entire app as an external-form - just to figure out all the functionality I wanted and see what it would look like etc.)

I watched a video from 5.3 and read the tutorial that went along with it but the two pages just can't seem to find each other. I figure either my directory structure in both the single_pages and controller directories are screwed up, or maybe my lack of name spacing is an issue.

I don't need anything fancy, just one single simple working example of the controller working with the view. Something like:

1. You need to have a file named view.php inside a directory named YourApplication that resides in the single_pages directory which resides in the application directory.
2. You need to have a controller file name controller.php that resides in the YourApplication directory which resides in Application/controller.
3. Your view needs to be namespaced such as x, y and z.
4. Your controller must have a view method.

Any help would be appreciated. Thanks.

View Replies:
codifyio replied on at Permalink Reply
I figured it out. I was over-thinking it, It was pretty straight forward. My namespace was wrong and how I was naming my PHP files.

In case anyone in the future has the same question:

In application/single_pages/ you have a file named mysinglepage.php
In application/controller/single_page/ you have a file (also named) mysinglepage.php

Now you can add the new page from dashboard/single pages:
Use the name of the file mysinglepage (no extension).

The controller needs a namespace:
namespace Application\Controller\SinglePage;

The controller class extends Controller (or PageController):
class Mysinglepage extends PageController {

To access variables declared in the controller for the single page, declare/define it:
protected $foo = "bar";

Add setting/getters etc:
public function getFoo(){
        return $this->get('foo');

Or you can set it in your start method:
public function on_start() {
             $this->set('foo', 'bar');

And to access that field from your view:
$myFoo = $controller->getFoo(); echo $myFoo;
ntisithoj replied on at Permalink Reply
this is a related answer, and new problems, with the same issue you posted here