Jaxel
Well-known member
Lets say I have an extra param in a URL with "?format=default"... How would I add this to the router? I tried extending the class with a listener... but for some reason, the contents of "$extraParams" is always empty in my extended class. It doesn't even have the stuff its supposed to have. How do I do this?
The contents of $extraParam is empty if I print_r it out.
Code:
<?php
class EWRporta_Listener_Route
{
public static function route($class, array &$extend)
{
switch ($class)
{
case 'XenForo_Route_Prefix_Threads':
$extend[] = 'EWRporta_Route_Thread';
break;
}
}
}
Code:
<?php
class EWRporta_Route_Thread extends XFCP_EWRporta_Route_Thread
{
public function buildLink($originalPrefix, $outputPrefix, $action, $extension, $data, array &$extraParams)
{
$response = parent::buildLink($originalPrefix, $outputPrefix, $action, $extension, $data, $extraParams);
if (!empty($extraParams['format']))
{
$split = explode('#', $response, 2);
$hash = !empty($split[0]) ? $split[0] : '';
return $split[0] . '?format=' . $extraParams['format'] . $hash;
}
return $response;
}
}
The contents of $extraParam is empty if I print_r it out.