XF 2.1 Route filters

Lawrence

Well-known member
I'm working on a widget that will display members viewing a Page node. Unlike forums and categories a Page node does not set the context option in the widget, so I use \XF::app()->request()->getRequestUri(); to look for /pages/ and then I pull the node name out to match it in the session activity table.

Then I decided to use a route filter (for testing). Since the filter removes the /pages/ part, there is no way to test to see if the URI is for a Page node or not. So I added \XF::app()->router('public')->getRouteFiltersIn() to grab the route filters. I'll need to loop through those to find a match in the replace_route key, to load in the find_route key value to test it to see if it is a page route or not. Before I do, is there a function that does this already? (Or is there a better way?) I've checked and could not find one.

Thanks for any guidance/suggestions.
 
I decided to just loop through getRouteFiltersIn() looking for a match against the Uri, and if it finds one it returns a string replacement of $uri using the value in $filter['find_route']. Works fine, as I only need it to retrieve a page node's name that is checked for in the session activity table ('node_name=' . $uri;).
 
Top Bottom