English 中文(简体)
使用插件中的 sh404SEF 路由器
原标题:Use sh404SEF router from a plugin

我正在开发一个 Joomla 2.5 内容插件, 当文章保存时, 需要编程创建 SEF url 。

I ve managed to make this work when the regular Joomla SEF is activated. My plugin is using the regular Joomla JRoute::_(); to build a SEF URL. This works great with native Joomla. For example the url

http://localhost/index.php?option=com_content&view=article&id=123

翻译为

http://localhost/index.php/mycategory/article-title-123.html

我的代码看起来是这样的:

private function joomlaSefUrl($article){
        require_once(JPATH_SITE.DS. components .DS. com_content .DS. helpers .DS. route.php );
        $siteURL = substr(JURI::root(), 0, -1);
        if(JPATH_BASE == JPATH_ADMINISTRATOR) {
            // In the back end we need to set the application to the site app instead
            JFactory::$application = JApplication::getInstance( site );
        }
        $articleRoute = JRoute::_( ContentHelperRoute::getArticleRoute($article->id, $article->catid) );
        $sefURI = str_replace(JURI::base(true),   , $articleRoute);
        if(JPATH_BASE == JPATH_ADMINISTRATOR) {
            $siteURL = str_replace($siteURL.DS. administrator ,   , $siteURL);
            JFactory::$application = JApplication::getInstance( administrator );
        }
        $sefURL = $siteURL.$sefURI;
        return $sefURL;
    }

问题在于当像 sh404SEF 这样的第三方扩展名被安装时, 我从使用 JRoute 获得的 SEF URL ::_ () 方法仍然是 Joomla 常规路线 url :

http://localhost/index.php/mycategory/article-123.html 

而不是预期的 sh404SEF s url

http://localhost/Mycategory/article-title.html

Joomla看不到 sh404SEF 是安装的, 所以通过使用 Jrout: (), 我总是得到常规的 SEF Joomla url 。 所以我需要找到一种方法使用 sh404SEF Jrout: () 类, 直接来自我的插件, 而不是常规的 Joomla 路由器 类 。

有谁知道SH404SEF课程是如何运作的吗?

问题回答

使用 Joomla! 要摆脱 URL 的 < code> index.php 部分, 您需要打开全球首选项中的 < code> mod_ rewrite 部分, 并启用与基本安装相伴随的 < code>. ht access 文件 。 (当你第一次安装 Joomla 时, 它被称为 < code> ht access. txt 重复并重命名副本为 < code>. ht access 。

欲知更多完整信息,请在Juomla Documents上查阅有关标准电子格式 URLs 的更多完整信息。

您可以在 JED < / a > 上尝试查看 < a href=" http://extensions.joomla.org/ extensions/extension- expecial/ ssh404sef- extensions " rel= "nofollow" >sh404SEF 插件的来源

在文件中使用函数获取 SefFrom unsef

管理器组件scom_sh404selfelferferfgener.php

示例:

$url =  index.php?option=com_content&view=article&id=1:aaaaaaaaa&catid=2&Itemid=101 
$sef_url = Sh404sefHelperGeneral::getSefFromNonSef($url, true, false, null);

记住,从索引开始... php?





相关问题
cross platform issues in webpages

I am developing some basic html pages, i am setting colors of text usimg color code #e7eddf it seems fine in windows but seems different in mac. Can you explain me why its happening and also ...

How to create breadcumb for custom component in Joomla?

I have a custom component in which I want to have a breadcumb to help the user navigate the previous page visits. The basic feature in my component is to show our product releases. The workflow is: ...

Preloading images

i ve a navigation bar like the one below..for each it changes the background color on mouseover and mouseout and there is a lag to load those images which looks awful :( i wanna know how to preload ...

Joomla conditional menu item

I d like to create a menu item in Joomla that points to one article when the user is logged out, and a different article when the user is logged in. I tried creating two menu items, and make them ...

unable to connect to database on AWS

actually I have my website build with Joomla hosted on hostmonster but all Joomla website need a database support to run this database is on AWS configuration files need to be updated for that I ...

How can you test if you re on the homepage in Joomla?

I m working on a Joomla site, and I need the front page to look slightly different from the rest of the pages, but not enough to warrant the use of two themes (it s a pain to have to update two ...

How to get the current Joomla username?

I m trying to get the current Joomla username. I was able to get it by using $user =& JFactory::getUser(); echo $user->username; But now I ve installed Joomla on my local server and it doesn ...