Page type controller
Permalink 1 user found helpful
Hello all,
I have crested a package that has a page type and a page type controller. I need a way to access that page type's controller from a different file. The following is not working.
$theController = Loader::controller('THE_PAGE_TYPE_HANDLE');
$result = $theController->THE_FUNCTION();
I would really appreciate any help I can get. HELP!!!
-Rachel
I have crested a package that has a page type and a page type controller. I need a way to access that page type's controller from a different file. The following is not working.
$theController = Loader::controller('THE_PAGE_TYPE_HANDLE');
$result = $theController->THE_FUNCTION();
I would really appreciate any help I can get. HELP!!!
-Rachel
YOU ROCK!!! That worked perfectly!!!
This is EXACTLY what I was trying to do.
Now here's a follow-up.. what would be the recommended method of ensuring that on all single_pages throughout the site run a certain method from my pagetype controller?
Now here's a follow-up.. what would be the recommended method of ensuring that on all single_pages throughout the site run a certain method from my pagetype controller?
single_pages don't have anything to do with page_type controllers. So I think your best bet is to just have something run on the on_start event (or some other event that happens early on in the C5 loading process), check if the requested page is a single_page (but probably wanting to exclude dashboard pages?), then run your method from there.
I am facing a similar problem. I have a package that contains a theme and in that theme i have created a custom page_type, pdftor
pdftor has a "hard coded" form, hard coded in the sense that it isn't part of a block.
I have created a folder like /packages/pdfcreator/theme/pdfcreator/pdftor.php
for the custom page
and
/packages/controllers/page_types/pdftor.php for the custom page controller
But it is not loading the controller, i have tested putting an echo on the on_page_view() function but it does not run it.
Any suggestions
?
Ramon
pdftor has a "hard coded" form, hard coded in the sense that it isn't part of a block.
I have created a folder like /packages/pdfcreator/theme/pdfcreator/pdftor.php
for the custom page
and
/packages/controllers/page_types/pdftor.php for the custom page controller
But it is not loading the controller, i have tested putting an echo on the on_page_view() function but it does not run it.
Any suggestions
?
Ramon
I'm not entirely sure, but I don't think you can have a theme folder in a package folder. You can just put a page_types folder in the package folder though.
You can have themes and page_types in your package (one, both, neither, whatever). But your package controller needs to install them. And you need to get the naming of things correct.
The theme needs to be in a folder called "themes" (note that it is plural, ending with the letter "s" -- not singular "theme" like you say you have), and inside that "themes" folder needs to be your theme's folder with the theme handle as the folder name. For example, if your theme has the handle "pdfcreator", then all your theme files would be in here:
Most marketplace themes have the package name prefixed with "theme_", which might be necessary, so try renaming your package to "theme_pdfcreator" (and the package handle in the package controller, and the package controller class name).
And make sure your install function of your package controller is actually installing the theme (or page_type, or whatever).
Good luck!
The theme needs to be in a folder called "themes" (note that it is plural, ending with the letter "s" -- not singular "theme" like you say you have), and inside that "themes" folder needs to be your theme's folder with the theme handle as the folder name. For example, if your theme has the handle "pdfcreator", then all your theme files would be in here:
/packages/pdfcreator/themes/pdfcreator/
Most marketplace themes have the package name prefixed with "theme_", which might be necessary, so try renaming your package to "theme_pdfcreator" (and the package handle in the package controller, and the package controller class name).
And make sure your install function of your package controller is actually installing the theme (or page_type, or whatever).
Good luck!
replace the handle and the controller name and method with your stuff.