Page Type Controller

Permalink 4 users found helpful
Anyone know how to setup a controller for global use by a theme instead of just single pages?

focus43
 
SteveAtParadigm replied on at Permalink Reply
Is this what you are looking for?
http://www.concrete5.org/index.php?cID=28266...
mdzoidberg replied on at Permalink Reply
mdzoidberg
You can create the controller inside your controllers folder and i believe you can just call it like this

Loader::controller($item);



Cheers.
focus43 replied on at Permalink Reply
focus43
Thanks for the responses, but couldn't get either of those to work.

I'm thinking it has to be something along the lines of what you're saying mdzoidberg... just cant get it.

I'll post if I figure it out.
dbaggs replied on at Permalink Best Answer Reply
dbaggs
Hey Jonohartman,

I needed to find this out too so I dug into the code to track how this could be done.

Ultimately, you need to create a controller within your controllers/page_types directory that is named after the Page Type handle. For example, in my case I have an 'event' Page Type and created an event.php file and placed it within the controllers/page_types folder, which I also had to create.

Most importantly, I named the class within <page type handle>PageTypeController (EventPageTypeController), which extends Controller. This is necessary because of how the controller is loaded NB: the 'PageType' section of the class name.

This has taken me a while to work out so I hope this helps.

Regards,

Dan
focus43 replied on at Permalink Reply
focus43
You are the man. Thanks!