2011-09-05 33 views
5

我在Magento adminpanel中的模塊具有類似於http://example.com/index.php/mymodule/的URL,幷包含具有訂單的自定義網格。當他點擊網格行時,我想將用戶重定向到標準的「訂購視圖」頁面。如何使用Magento中的getUrl()引用另一個模塊?

public function getRowUrl($row) 
{ 
    if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/view')) { 
     return $this->getUrl('sales_order/view', array('order_id' => $row->getId())); 
    } 
    return false; 
} 

但這個URL指向http://example.com/index.php/sales_order/view/ ......而不是http://example.com/index.php/管理的/sales_order的/圖/ ...任何建議?

UPD。 config.xml中

<admin> 
    <routers> 
     <mymodule> 
      <use>admin</use> 
      <args> 
       <module>Foo_Mymodule</module> 
       <frontName>mymodule</frontName> 
      </args> 
     </mymodule> 
    </routers> 
</admin> 
+1

看看正確的配置[如何獲取Magento管理員頁面/部分的URL](http://stackoverflow.com/questions/6877683/how-to-get-the-url-of -a-page-section-in-magento-admin/6881211#6881211) – clockworkgeek

+0

@clockworkgeek謝謝。請看看我更新的帖子。它看起來與config.xml的情況相似,不是嗎? – silex

+0

您的'frontName'是'mymodule',但如果您更仔細地複製示例,則可以使用'admin'代替。 – clockworkgeek

回答

7

很簡單,你需要*/sales_order/view更換sales_order/view*表示使用管理員中的當前路由器是adminhtml

編輯
爲了更詳細地把這個在你的配置說明,

<admin> 
    <routers> 
     <adminhtml> 
      <args> 
       <modules> 
        <mymodule after="Mage_Adminhtml">Foo_Mymodule_Adminhtml</mymodule> 
       </modules> 
      </args> 
     </adminhtml> 
    </routers> 
</admin> 

現在價值*/mymodule/index將生成一個URL http://example.com/index.php/admin/mymodule/index這反過來將加載該文件Foo/Mymodule/controllers/Adminhtml/MymoduleController.php並試圖找到方法Foo_Mymodule_Adminhtml_MymoduleController::indexAction()。如果方法存在,則運行該方法,否則管理路由器將接管並顯示404或重定向到儀表板。

+0

用'*/sales_order/view'指向'http:// example.com/index.php/mymodule/sales_order/view /'。我也很驚訝。 – silex

+1

感謝您的評論,我已經完全重寫了佈局配置中的路由和路徑,所以現在''/ sales_order/view'現在一切正常。 – silex

+0

你是如何改寫的?我也有完全一樣的問題!使用**/sales_order/view *還會將我重定向到* index.php/mymodule/sales_order/view/*,而不是* index.php/admin/sales_order/view/*。謝謝你的幫助! – EOB

相關問題