admin管理员组

文章数量:1192157

In joomla 3 I use the "simple custom router manager" plugin where I configured a regex rule with which I can render a menu item (article). How can I replicate the same thing in joomla 5?

This is simple custom router manager in joomla 3

I tried to create a custom plugin but I end up on the 404 page.

<?php
defined('_JEXEC') or die;

use Joomla\CMS\Plugin\CMSPlugin;
use Joomla\CMS\Factory;
use Joomla\CMS\Uri\Uri;

class PlgSystemCustomRouter extends CMSPlugin
{
    public function onAfterInitialise()
    {
        $app = Factory::getApplication();

        if ($app->isClient('site'))
        {
            $input = $app->input;
            $uri  = Uri::getInstance();
            $path = $uri->getPath();

            if (preg_match('#^viaggi/(\d+)-([a-zA-Z0-9-]+)$#', $path)) {
                $input->set('option', 'com_content');
                $input->set('view', 'article');
                $input->set('id', 2);
                $input->set('Itemid', 104);   
            }
        }
    }
}

本文标签: Custom plugin for routing in Joomla 5Stack Overflow