In my current Contrete5 project, I have a single page, that takes one url parameter. So the urls look like this:
domain.com/[singlepagename]/[id]
and the controller has a corresponding view function:
function view($id) { ... }
now i need access to the id in the on_start() function. but function on_start($id) { ... } throws an error and $this->get() returns an empty array.
any idea how i can get url parts in on_start()?
I’ve encountered this before… the problem is that C5’s Request object is not initialized until after the various package controllers’ on_start events are fired. I believe the only solution that people came up with was to manually initialize the Request class yourself in you package controller’s on_start function. If you look at the dispatcher.php file, you’ll see the following chunk of code around line #129 (in Concrete5.6.0.1):
…so I think you can copy that all into your package controller’s on_start function, then you have the
$reqobject to get your path info and variables from.NOTE: I copied that code from Concrete5.6.0.1. If you’re using a different version of the system, you should not just take what I pasted above, but instead copy the appropriate code yourself from the
/concrete/dispatcher.phpfile