Where do I put controller code in a theme (for redirecting to another page)?
Permalink
For a page type in the theme I created (contact.php) I need to have a page of this type redirect to one of its children, based upon certain attribute values. I was writing this bit of code in the contact.php view itself, but came to a hold when I found that I can't redirect to another page from the view.
It makes more sense to do this in controller code anyway, but I'm having a hard time finding where to "put controller code" in a theme. What is the best way to do this?
It makes more sense to do this in controller code anyway, but I'm having a hard time finding where to "put controller code" in a theme. What is the best way to do this?
Thanks Michael. I did find that post already, but it hasn't gotten me there quite yet.
So in my theme folder, I created controllers/page_types/contact.php with the following test content:
But that code does not get hit (or executed), since there is no redirect happening. Maybe I'm using the wrong function to do this in?
So in my theme folder, I created controllers/page_types/contact.php with the following test content:
But that code does not get hit (or executed), since there is no redirect happening. Maybe I'm using the wrong function to do this in?
"So in my theme folder..." is incorrect. [root] is not your theme folder. [root] is the base folder where concrete5 is installed. Perhaps I should have referred to the location for the controller as [public_html]/controllers/page_types/contact.php
Darn, you're right Michael. That was exactly the problem. Now that I have put it in my [concrete5 root]/controllers/page_types, it works.
Thanks for helping me out!
Thanks for helping me out!
Happy to help.
This might help get you going:
http://www.concrete5.org/community/forums/customizing_c5/page-type-...