fahad ashraf Well-known member May 9, 2021 #1 Hey , is there any way to get current route parameterbad outside controller ??
Jeremy P XenForo developer Staff member May 9, 2021 #2 It depends what you're trying to accomplish. You could hook a controller_* event which receives the ParameterBag object directly, or you could hook a dispatch_* event and get it through the RouteMatch object (via $match->getParameterBag()).
It depends what you're trying to accomplish. You could hook a controller_* event which receives the ParameterBag object directly, or you could hook a dispatch_* event and get it through the RouteMatch object (via $match->getParameterBag()).
Lukas W. Well-known member May 10, 2021 #3 You can try to construct it dynamically like the thread from URL method does: PHP: $routePath = $this->app()->request()->getRoutePathFromUrl($url); $routeMatch = $this->app()->router($type)->routeToController($routePath); $params = $routeMatch->getParameterBag(); The current URL can be accessed with: PHP: \XF::app()->request()->getRoutePath();
You can try to construct it dynamically like the thread from URL method does: PHP: $routePath = $this->app()->request()->getRoutePathFromUrl($url); $routeMatch = $this->app()->router($type)->routeToController($routePath); $params = $routeMatch->getParameterBag(); The current URL can be accessed with: PHP: \XF::app()->request()->getRoutePath();