But there is no page called somethingmore. It's a page I want to create dynamically. So I would like a controller to be called when the url starts with /something/ and then build the page based on the remaining part of the url. How would I do that?
I *think* this is only possible if the top-level /something/ page is a single_page. If that's the case, then what you do is add a new public function called "somethingmore()" to that single_page controller (in YOURSITE/controllers/something.php) and it should respond to that url. Note that unfortunately C5 doesn't allow you to have more than one view file for a single controller, so if you want the somethingmore page to look different than the something page, you need to put a big IF statement in the view (in YOURSITE/single_pages/something.php).
That could work but the problem is that a don't know the real string 'somethingmore'. It will be the name (slug) of a page, and those can also be added later. So unfortunately I can't create a method with that name. I need a method that will run whatever the 'somethingmore' is.
Anything else in the URL gets passed to the controller's method as a parameter. So if you have your singlepage, with a default method you can handle a dynamic/unknown page in that method and output what you need dependent on what is passed. You just need to decide on a naming convention for the single page controller and method.
Ollie is right, but make sure you allow for the appropriate number of arguments in your "catch-all" method.
If you're expecting a url like /something/somethingmore/arg1/arg2, you'd want a method like public function view($page, $arg = null, $arg2 = null) {}. Otherwise c5 says "i have three arguments and no method will accept those, must be a 404".
Code
Post Reply
Delete Post
You are allowed to delete your post for 5 minutes after it's posted.