Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/magento/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/blackberry/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Magento路由器Url-需要连字符路径名_Magento_Path_Controller_Router - Fatal编程技术网

Magento路由器Url-需要连字符路径名

Magento路由器Url-需要连字符路径名,magento,path,controller,router,Magento,Path,Controller,Router,比方说,我使用一个自定义控制器来拥有url路径/前端名称 /customcategory 很明显,如果我有一个名为“TestController.php”的控制器文件和indexAction url路径将是 /customcategory/test/index 我试图弄清楚的是如何重新命名测试控制器,或修改配置xml文件,以便从控制器文件(如 /customcategory/test-section/index 我知道如果我想将/customcategory连字符,我可以修改配置文件中的前

比方说,我使用一个自定义控制器来拥有url路径/前端名称

/customcategory
很明显,如果我有一个名为“TestController.php”的控制器文件和indexAction url路径将是

/customcategory/test/index
我试图弄清楚的是如何重新命名测试控制器,或修改配置xml文件,以便从控制器文件(如

/customcategory/test-section/index
我知道如果我想将
/customcategory
连字符,我可以修改配置文件中的前端标记。但我正在建设的网站将受益于连字号控制器路由,该部分位于
/customcategory
之后,带有关键字,我无法让它工作,也无法在谷歌上找到一个例子——这可能看起来很疯狂


谢谢您的时间。

据我所知,您无法在url中添加hypens以匹配文件名。如果你想得到一个文件夹结构,你可以添加更多的路径

例如,如果您想要:

Namespace/CustomCategory/controller/test/SectionController.php
你可以做:

/customcategory/test_section/index

您尝试在自定义模块中使用全局重写是可能的。您可以将
/customcategory/*
的所有传入请求传递给特定的控制器操作。但是您必须管理自己的路由(基于url路径的深度)

e、 g
www.MageIgniter.com/customcategory/path1/path2

config.xml

<global>
    <rewrite>
      <fancy_url>
            <from><![CDATA[/customcategory\/(.*)/]]></from>
            <to><![CDATA[customcategory/index/processroute/tagname/$1/]]></to>
            <complete>1</complete>
       </fancy_url>
    <rewrite>
</global>
<frontend>
    <routers>
        <tagseo>
            <use>standard</use>
            <args>
                <frontName>customcategory</frontName>
            </args>
        </tagseo>
    </routers>


class MageIgniter_Customcategory_IndexController extends Mage_Core_Controller_Front_Action
{
     public function processRoute(){
           print_r($requestUri = Mage::app()->getRequest()->getRequestUri()); //path1/path2
           print_r($this->getRequest()->getParam('tagname')); // path1
           print_r($this->getRequest())
           // do you custom logic here base on about request path explode('/', trim($requestUri,'/'))

     }
     ...

1.
标准

很有趣。这是一个很好的观点,只需在controller文件夹中添加一个子目录。好的,它是下划线而不是连字符。很高兴知道我能够确认Magento允许连字符是不自然的。除了.htaccess魔术,我不确定我是否错过了一些让它工作的“技巧”。谢谢。您是否正在尝试使用以下结构的url。。。xyz.com/customcategory/what-ever-hyphnated-path-i-want.html。。。xyz.com/customcategory/hyphnated-path-2.html…等等?是的。因此,无论我在自定义控制器中使用什么控制器文件,我都可以完全控制该路径。请查看“产品标签”部分,让我知道这是否是您试图实现的目标。是的,只要它来自我的自定义控制器,而不是来自标准类别url。谢谢。那不是一个分类url。。产品标签的定制非常有趣。这个周末我要试试。对此我感激不尽。