我製作了joomla 2.5(在Joomla 3中工作)組件。爲了測試組件,我創建了一個菜單項「mycomtest-main」,並將組件放置在該菜單項中。完整的本地測試網址是「localhost/joomla/mycomtest-main」。組件列出了很多項目,並且當單擊條目窗體顯示時有一個按鈕,這是我的那個mvc組件的入口窗體視圖,url變成了「localhost/joomla/mycomtest -main?task = edit & id = 4「,因爲我使用JRoute :: _(」index.php?...「)來保存sef url.So在上面的表單填寫並提交之後,它被重定向回默認值view - localhost/joomla/mycomtest-main,但不幸的是url變成了 - localhost/joomla/component/mycomtest-main /而不是localhost/joomla/mycomtest-main。我的組件報名表視圖外觀如下 -無法在joomla mvc組件中正確實現jroute功能
<form action="index.php" method="post" name="adminForm" id="adminForm" enctype="multipart/form-data">
<input type="hidden" name="option" id="option" value="<?php echo $_REQUEST['option']; ?>" />
<input type="hidden" name="task" id="task" value="save" />
<input type="hidden" name="id" id="id" value="<?php if($row!=NULL){ echo $row->id; }?>" />
<input type="hidden" name="page" id="page" value="<?php echo JRequest::getVar('page'); ?>" />
.............rest of the html contents along with submit button
</form>
而且在我的MVC組件的Controller.php這樣的文件我用JROUTE通過這一方法 -
function save()
{
$model = $this->getModel('entry');
if($model->store())
{ $msg = "saved successfully"; $type = 'message'; }
else
{ $msg = 'error found'; $type = 'error';
}
$urlSet=JRoute::_("index.php?option=". $_REQUEST['option']."");
$this->setRedirect($urlSet, $msg, $type);
}
所以,我怎麼去讓後進入查看錶單提交我被重定向到菜單項頁面 正確的URL在下面? -
http://localhost/joomla/mycomtest-main/
請儘快幫忙