2012-08-24 122 views
0

我正在使用Magento CE 1.7。Magento:如何重定向表單提交

我創建了CMS頁面以向其添加「使用條款」,並在頁面底部添加了一個簡單的「接受條款」提交表單,讓客戶在訪問頁面之前同意這些條款I希望他們訪問。這是代碼。

<form action="url-to-go-to.html" method="GET" onsubmit="return checkCheckBox(this)"> 
I accept: <input type="checkbox" value="0" name="agree"> 
<input type="submit" value="Continue"> 
<input type="button" value="Exit" onclick="document.location.href='BACKTOWHAT.html';"> 
</form> 

<script type="text/javascript"> 
<!-- 
function checkCheckBox(f){ 
if (f.agree.checked == false) 
{ 
alert("Please tick the box to continue"); 
return false; 
} else 
return true; 
} 
--> 
</script> 

我唯一的問題是,我只能得到它通過輸入URL來我想讓他們被重定向到網頁的工作。即

<form action="domainname.com/shop.html"> <!-- store section to go to --> 
/* and the same goes for */ 
onclick="document.location.href='domainname.com';"> <!-- back to storefront --> 

我想使用別的東西而不是URL,但我不知道該怎麼做。我認爲使用這樣的東西會起作用。

<form action="<?php echo $this->_redirect('shop.html'); ?>" method=.... > 

但它沒有。

我相信如果這已經在.phtml文件中,它會工作,但我正在使用一個簡單的CMS頁面,我知道magento函數在CMS頁面中工作,但我不知道一個可以工作的函數以此目的。

回答

1

好吧,我在測試多一點之後就知道了。 (我還在學習如何編碼)

這很簡單,表單動作應該是這樣的。

<form action="{{store direct_url='shop.html'}}" method=..... > 

並重定向回到商店前面的「退出」這是什麼工作。

onclick="document.location.href='{{store direct_url=' '}} 

這工作完美。希望它能幫助別人。