admin管理员组文章数量:1391008
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
本文标签: friendly urlXenforo custom topic URLsStack Overflow
版权声明:本文标题:friendly url - Xenforo custom topic URLs - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744594096a2614670.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论