简体   繁体   English

如何将joomla表单(在文章中)重定向到不同的joomla文章?

[英]How to redirect a joomla form (in article) to differents joomla articles?

This question is very particular to my case and I could'nt fin any solution on Joomla.org forum and others. 这个问题对我的情况而言非常特殊,我无法在Joomla.org论坛和其他网站上找到任何解决方案。

I have some joomla articles to display my prices table. 我有一些joomla文章来显示我的价格表。 I need several articles to display several prices (for simple coupon system). 我需要几篇文章来显示几种价格(用于简单的优惠券系统)。

So I have my main prices article with a COUPON field form which redirect to the prices article with discount. 因此,我的主要价格文章带有COUPON字段表单,该表单重定向到带有折扣的价格文章。

 <form class="form-inline" name="myForm" action="/index.php?option=com_content&view=article&id=15&Itemid=229" onsubmit="return validateForm()" method="post"> <label for="fname">Code Promo:</label> <input type="text" name="fname" value="PROMO2018"> <input class="btn btn-success" type="submit" value="Valider ce code"> </form> 

If user doesn't type PROMO2018, there is an error popup. 如果用户未输入PROMO2018,则会弹出错误消息。 Otherwise, user is redirected by form to my other prices article with disount applied. 否则,将通过表单将用户重定向到我的其他价格文章,并应用disount。

 <script> function validateForm() { var x = document.forms["myForm"]["fname"].value; if (x != "PROMO2018") { alert("Le code PROMO n'est pas bon. Désolé. :-( "); return false; } } </script> 

This tiny javascript hack let me managing my sales with a simple 1 coupon system for my product. 这个小巧的JavaScript骇客让我可以使用简单的1张优惠券系统管理我的商品。

I would like now to work with several coupons. 我现在想使用几个优惠券。 In fact, I need a 2nd one for another discount. 实际上,我需要第二个折扣。 So it will redirect to another joomla article prices with other prices. 因此它将与其他价格一起重定向到另一个joomla商品价格。

So I wrote this javascript: 所以我写了这个javascript:

 <script> function validateForm() { var x = document.forms["myForm"]["fname"].value; if (x == "PROMO2018") { document = "index.php?option=com_rsform&view=rsform&formId=8&Itemid=484"; } else { if (x == "ETUDIANTBDX") { location = "index.php?option=com_rsform&view=rsform&formId=4&Itemid=232"; } else { alert("Le code PROMO n'est pas bon! Veuillez essayer un autre svp."); return false; } } } </script> 

But it doesn't work! 但这不起作用! :-( :-(

Does anyone can tell me why user is not redirected to appropriate page when submiting coupon form. 有谁能告诉我提交优惠券表格时为什么用户没有重定向到适当的页面。

THanks for your help. 谢谢你的帮助。

I Follow your advice with RSFORM 我通过RSFORM遵循您的建议

And I did this code: 我做了这段代码:

 $v_coupon = $_POST['form']['coupon']; switch ($v_coupon) { case "PROMO2018": case "ETUDIANTBDX": echo ""; break; default: echo "<script type='text/javascript'>alert('Le code PROMO n'est pas bon! Veuillez essayer un autre svp.');</script>"; break; } 
It works, the only problem is for default case. 它有效,唯一的问题是默认情况。 It doesn't show the popup error message if I type a wrong coupon code. 如果输入错误的优惠券代码,它不会显示弹出错误消息。

The solution to my question is RSFORM with a custom validation rule. 我的问题的解决方案是使用自定义验证规则的RSFORM。

The tutorial to create RSFORM validation rule is here 创建RSFORM验证规则的教程在这里

The code I inserted was this one: 我插入的代码是这样的:

 <?php defined( '_JEXEC' ) or die( 'Restricted access' ); require_once dirname(__FILE__).'/validation.php'; class RSFormProCustomValidations extends RSFormProValidations { public static function validationTest($value, $extra = null, $data = null) { // The following makes sure the submitted value is "test" if ($value == "PROMO2018") { $app = JFactory::getApplication(); $app->redirect('index.php?option=com_content&view=article&id=165&Itemid=483'); return true; } elseif ($value == "ETUDIANTBDX") { $app = JFactory::getApplication(); $app->redirect('index.php?option=com_content&view=article&id=15&Itemid=229'); return true; } else { // Return false if the validation didn't pass. return false; } } } 

This simple coupon solution let me manage the sale of my products with discount. 这个简单的优惠券解决方案使我可以打折管理商品的销售。

Joomla Article=>RSformCoupon=>Joomla Article with discount=>RsformStripe=> Payment Joomla文章=> RSformCoupon =>具有折扣的Joomla文章=> RsformStripe =>付款

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM