Dannymh
Active member
Hi,
I have the following code in my controller class (extends abstractContrller as this is a custom controller)
Then I have the public function inside that class
I have a route in place that lets call it
content
Content has a route path of
Now when I call a Url of something like
mysite.com/content/this-slug
My code will recognise the param and that there is a slug there, but instead of re-routing to actionView it returns an oops error that instead says
So instead of calling the actionView its trying to use the slug as the controller action from the param. Am I using this wrong? I assumed I could use that variant slug to still call the view action without needing to explicitly route for it or have I wildly misunderstood this.
What I am trying to do is avoid having to set up an additional route and have it call the route/function I want based on the presence of the slug param. I cold avoid this by setting up a route such as content/view/slug but this wouldn't be ideal
I have the following code in my controller class (extends abstractContrller as this is a custom controller)
PHP:
if($params->slug)
{
return $this->rerouteController(__CLASS__, 'actionView', $params);
}
Then I have the public function inside that class
Code:
public function actionView(ParameterBag $params)
{
echo "That worked";
}
I have a route in place that lets call it
content
Content has a route path of
:int<slug>/:page
Now when I call a Url of something like
mysite.com/content/this-slug
My code will recognise the param and that there is a slug there, but instead of re-routing to actionView it returns an oops error that instead says
The requested page could not be found. (Code: invalid_action, controller: Silvertails\Content:Content, action: ThisSlug)
So instead of calling the actionView its trying to use the slug as the controller action from the param. Am I using this wrong? I assumed I could use that variant slug to still call the view action without needing to explicitly route for it or have I wildly misunderstood this.
What I am trying to do is avoid having to set up an additional route and have it call the route/function I want based on the presence of the slug param. I cold avoid this by setting up a route such as content/view/slug but this wouldn't be ideal