I want to change topics urls in xenforo to this format example/f8/tapatalk-2/
8 is Id forums, and 2 is topic id
i create an addon "CustomThreadRoute" my addon.json codes is:
{
"title": "Custom Thread Route",
"version_id": 1000000,
"version_string": "1.0.0",
"dev": "Your Name",
"dev_url": ";,
"description": "A custom listener to change thread URLs",
"actions": [
{
"action": "XF\AddOn\AbstractAddOn::install",
"execute_order": 10
}
],
"listeners": [
{
"event": "router_public",
"action": "CustomThreadRoute\Listener::routerPublic"
},
{
"event": "router.build_link",
"action": "CustomThreadRoute\Listener::generateUrl"
}
]
}
and Listener.php is
<?php
namespace CustomThreadRoute;
use XF\Mvc\RouteBuiltLink;
use XF\Mvc\Router;
class Listener
{
// اصلاح مسیرها
public static function routerPublic(Router $router, array &$routes)
{
$routes['custom-route/{thread_id}-{title}'] = 'threads/view';
}
// تولید لینکهای جدید
public static function generateUrl(RouteBuiltLink $link, $route, array &$data, array &$parameters)
{
if ($route === 'threads' && isset($data['thread_id'])) {
$link->route = 'custom-route';
$link->params = [
'thread_id' => $data['thread_id'],
'title' => $data['title']
];
}
}
}
also i add code event listener
enter image description here
but not working and urls not change why?
i try to create an addon for custom urls