bypass joomla menu system

戏子无情 提交于 2019-12-13 07:12:47

问题


I would love a code snippet that allowed me to intercept the URL given and then depending on a parameter serve a specific page.

The purpose would be that no matter the url if the last part of the url had say '/blah' the page I wanted would display.

ex 1: http://website/index.php/blah/
ex 2: http://website/index.php/blogcategory/articlex/blah/
ex 3: http://website/index.php/blogcategory/article5/blah/

Would all show the same article.

Thanks,

Mat


回答1:


You need a plugin that is triggered 'onAfterInitialise'. Have a look at:

http://docs.joomla.org/Plugin/Events/System#onAfterInitialise

The code you need for your function would be something like (not tested):

/**
* Do something onAfterInitialise
*/
function onAfterInitialise()
{
    // check for occurrence of string in url
    $findme = 'blah';
    $myuri = JRequest::getURI();
    $tocheck = strpos($myuri, $findme);

    if ($tocheck === true) {
        $app = JFactory::getApplication();
        $app->redirect('/anywhereyouwant'); 
    }
}


来源:https://stackoverflow.com/questions/9780857/bypass-joomla-menu-system

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!