2

我可以看到整个互联网上的人都在谈论这个。使用时JRoute::_($URL),我们被迫计算第Itemid一个,然后将其附加到输入 URL,如:

JRoute::_('index.php?option=com_abc&view=xyz&id=32'.'&Itemid='.$itemid);

但是,总是希望Itemid从给定 URL 的 Joomla 核心路由器中自动计算。

从今天的 Joomla 1.5 到 3.2,

JRouterSite::_buildSefRoute或最新的JRouterSite::buildSefRoute

没有显着变化。

我可以在/libraries/cms/router/site.php文件中的代码中看到,要构建所需格式的 sef URL,必须包含Itemid=XXX在传递的 URL 中。否则

JRoute::_('index.php?option=com_abc&view=xyz&id=32');

将生成一个类似的 URL

`/component/abc/?view=xyz&id=32` 

不像想要的

/our-component/?id=32

our-component指向的菜单项的菜单别名在哪里

index.php?option=com_abc&view=xyz

我知道后半部分?view=xyz&id=32可以通过使用每个组件的自定义 router.php 文件来处理。但是组件基本 URL/component/abc超出了该自定义 router.php 的范围

请有人告诉我这个想法是正确的还是我错过了一些重要的东西。还建议我如何克服这个问题。

4

1 回答 1

1

The /component/abc is generated by the Joomla routing. Your component router.php will take care of the parameters which the component handles, so your /our-component/?id=32 may be translated into /our-component/my-id32-alias. It's not desirable that any component can tweek the basic routing on which all other components are based, and that's why you only can make-up part of the URL using router.php

Maybe you can investigate how to augment the router using a system plugin, but I think it is not what you are looking for.

http://docs.joomla.org/J2.5:Creating_a_System_Plugin_to_augment_JRouter

I've read it many times, but I find it hard to understand.

于 2014-03-12T09:48:11.323 回答