1

我对 joomla 1.5 友好 url 有问题(实际上不是那么友好)我现在没有使用 SEF(我应该吗?)

这是我的问题

我有一些类别和部分。每个都有别名。

所以我可以查看所有新闻类别,例如访问 www.myxyz.com/news/

要查看文章,生成的 url 将变为:www.myxyz.com/news/10-local-news-title-alias

我不知道 joomla 如何生成该 url。在我的模板中,我需要生成一些指向特定文章的链接。

所以我在模板中创建了一个助手:


// helper to get alias in mainMenu ... alias must be unique 
function getMainMenu($menuAlias){
    $items = &JSite::getMenu();
    // Get Menu Items
    $rows = $items->getItems('alias', $menuAlias);
    if($rows){
        //$result = JRoute::_(JURI::base().$rows[0]->link);
        $result= JURI::base().substr(JRoute::_($rows[0]->link), strlen(JURI::base(true)) + 1);
        return $result;
    }else{
        return JURI::base() ;// aka not found
    }
}

但是当我进入像 www.myabc.com/news/7-local-news-alias 这样的页面时,网址会变得混乱并更改为错误的网址。

我应该使用 SEF 对 joomla url 友好吗?

4

2 回答 2

2

You should just work with normal url's in your code. when you turn on SEF joomla! will automaticly convert all links you create to SEF urls and when a request comes in it will revert them back to regular url's for you...

于 2009-09-24T07:12:09.930 回答
2

这有点令人费解,但链接到 SEF URL 的正确方法是使用原始的非 SEF 链接。你会需要:

  • 文章ID
  • 您的部分的菜单项的 Itemid(例如链接到文章博客布局的菜单项等)

然后你只需链接到:

index.php?option=com_content&view=article&id=42&Itemid=3

其中 42 是文章 ID,3 是菜单 ID。您的链接将如下所示:

/section-alias/42-the-article-alias

如果您错过了 Itemid,您的链接将如下所示(我认为):

/components/content/42-the-article-alias
于 2009-09-29T17:10:51.080 回答