我需要从 url 传递字符串:
../page.html?code=123456
到表单(modx 中的 eform 片段)只加载一次页面(带有 url 和参数的链接)感谢您的回答...
我需要从 url 传递字符串:
../page.html?code=123456
到表单(modx 中的 eform 片段)只加载一次页面(带有 url 和参数的链接)感谢您的回答...
我的解决方案:
1. 创建一个名为 GetCode 的新代码段
<?php
if( !function_exists('eformGetCode') ) {
function eformGetCode(&$fields,&$templates){
global $modx;
$code = strip_tags($_GET['codeID']);
$templates['tpl']=str_replace('[+display_code+]',$code,$templates['tpl']);
return true; } }
return '';
?>
2. 在网页上添加 eform 调用(和代码片段):
[!GetCode!]
[!eForm? ... ... &eFormOnBeforeFormParse=`eformGetCode` !]
3. 在带有表单代码的 eform 块中添加行:
<input name="code" id="code" value="[+display_code+]" eform="::1:" type="text"/>
5. 现在,当您将参数放入 url 时,例如:
..../page.html?code=123456
这应该以形式出现。
你会像在 php 中那样做这件事。
$myVar = $_GET['code'];
如果您遇到问题,请查看 modx 错误日志...
-肖恩
KudyKam 的解决方案比他们使用数据库的 MODX 文档中的官方解决方案要好。http://wiki.modxcms.com/index.php/Populate_eform_with_dynamic_data