Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/google-chrome/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Joomla JMail代码不工作-Javascript工作正常_Javascript_Php_Jquery_Email_Joomla - Fatal编程技术网

Joomla JMail代码不工作-Javascript工作正常

Joomla JMail代码不工作-Javascript工作正常,javascript,php,jquery,email,joomla,Javascript,Php,Jquery,Email,Joomla,在这里,我将尽量详尽和简短。我目前第一次在Joomla工作,但我以前有过发展。我正在使用Joomla 3.4。我想做的是: 用户通过一个特定的页面注册我们的时事通讯,该页面将他们指向优惠券。 下一页显示优惠券,URL中有一个电子邮件标签(即&email='email') 我试图在一个模块内编码,解析出该电子邮件,并自动将优惠券副本发送给该电子邮件用户 我不能在任何用户订阅时使用通用自动电子邮件,因为只有从特定页面注册的用户才能获得优惠券。我已经关闭了所有文本过滤,正在使用基本模块编辑器。当我保存

在这里,我将尽量详尽和简短。我目前第一次在Joomla工作,但我以前有过发展。我正在使用Joomla 3.4。我想做的是: 用户通过一个特定的页面注册我们的时事通讯,该页面将他们指向优惠券。 下一页显示优惠券,URL中有一个电子邮件标签(即&email='email') 我试图在一个模块内编码,解析出该电子邮件,并自动将优惠券副本发送给该电子邮件用户

我不能在任何用户订阅时使用通用自动电子邮件,因为只有从特定页面注册的用户才能获得优惠券。我已经关闭了所有文本过滤,正在使用基本模块编辑器。当我保存模块时,代码在编辑框中显示得很好。当我查看页面的源代码时,脚本标记仍然存在,但是代码都是空白的。我现在已经进入phpmyadmin,可以直接在那里编辑模块。现在,脚本显示得很好

我尝试了许多不同的修复,包括添加
jQuery($)
函数加载,以绕过mootools的任何问题。不知道这是否是Javascript的问题,我清除了脚本并发出了一个简单的
警报(“测试…”)在页面上正常启动的脚本。这意味着,在我的完整脚本中,一定有某些内容无法正常工作。任何帮助或其他想法都会很好。我已经花了一天多的时间在这件事上了,我已经不知所措了。代码如下:

<script type="text/javascript">
function get(name){
   if(name=(new RegExp('[?&]'+encodeURIComponent(name)+'=([^&]*)')).exec (window.location.search))
    $recipient = decodeURIComponent(name[1]);
}

$mailer = JFactory::getMailer();

$config = JFactory::getConfig();
$sender = array(
    $config->get( 'config.mailfrom' ),
    $config->get( 'config.fromname' )
);

$mailer->setSender($sender);

get('email');

$mailer->addRecipient($recipient);

$body = '<h2>Thank you for joining our mailing list!</h2>
    '<div>Here is your coupon for a FREE 8" 1-topping pizza at Goodfellas!'
    '<img src="http://www.goodfellas309.com/main/images/pizzacoupon.jpg" alt="pizza coupont"/></div>';
$mailer->isHTML(true);
$mailer->Encoding = 'base64';
$mailer->setSubject('Your Free Pizza!');
$mailer->setBody($body);

$send = $mailer->Send;
if ( $send !== true ) {
    echo 'Error sending email: ' . $send->__toString();
} else {
    alert("An email with your coupon has been sent to you! Thank you for joining our mailing list!");
}
');
</script>

函数get(名称){
if(name=(新的RegExp('[?&]'+encodeURIComponent(name)+'=([^&]*)).exec(window.location.search))
$recipient=decodeURIComponent(名称[1]);
}
$mailer=JFactory::getMailer();
$config=JFactory::getConfig();
$sender=数组(
$config->get('config.mailfrom'),
$config->get('config.fromname')
);
$mailer->setSender($sender);
获取(“电子邮件”);
$mailer->addRecipient($recipient);
$body='感谢您加入我们的邮件列表!
“这是您在Goodfellas免费购买8”1顶比萨饼的优惠券!”
'';
$mailer->isHTML(true);
$mailer->Encoding='base64';
$mailer->setSubject(“您的免费比萨饼!”);
$mailer->setBody($body);
$send=$mailer->send;
如果($send!==true){
echo“发送电子邮件时出错:”。$send->_-toString();
}否则{
提醒(“已向您发送了一封带有优惠券的电子邮件!感谢您加入我们的邮件列表!”);
}
');
我甚至尝试过通过Joomla进行内联PHP解析,代码包装了javascript:

<?php

$document = JFactory::getDocument();
$document->addScriptDeclaration('
-Javascript here-
');
?>


我一直都很喜欢StackOverflow,回答的问题让我摆脱了很多困境。我只是到处都找不到答案。谢谢你的时间!

将以下内容放在你的模块中

<?php

// Get the email from the url
$jinput = JFactory::getApplication()->input;
$recipient = $jinput->get('email', '', 'string');

$mailer = JFactory::getMailer();

$config = JFactory::getConfig();
$sender = array(
    $config->get( 'config.mailfrom' ),
    $config->get( 'config.fromname' )
);

$mailer->setSender($sender);

$mailer->addRecipient($recipient);

$body = '<h2>Thank you for joining our mailing list!</h2>'
        .'<div>Here is your coupon for a FREE 8" 1-topping pizza at Goodfellas!'
        .'<img src="http://www.goodfellas309.com/main/images/pizzacoupon.jpg" alt="pizza coupont"/></div>';

$mailer->isHTML(true);
$mailer->Encoding = 'base64';
$mailer->setSubject('Your Free Pizza!');
$mailer->setBody($body);

$send = $mailer->Send;
if ( $send !== true ) {
    echo '<script type="text/javascript">Error sending email: ' . $send->__toString() . '</script>';
} else {
    echo '<script type="text/javascript">alert("An email with your coupon has been sent to you! Thank you for joining our mailing list!");</script>';
}

你的javascript和php都混在一起了。php部分不知道js在做什么,也不知道在哪里发送电子邮件。此外,
标记中包含的php代码没有包含在
标记中,因此它根本不会被解析为代码。如果你不将这两个标记分开,也不会得到('email');
不会做任何事,也不会发出警报(“带有…
的电子邮件会提醒任何事情,因为它是php内部的js代码,格式不正确。
是修复javascript不起作用的一项努力。
我只是想表明我自己尝试了一些我甚至认为不起作用的事情。Joomla网站显示,你可以嵌入带有该标记的javascript,所以我尝试了显然没有用。我只是不想浪费时间而不尝试我能找到的一切。当前的设置只是
部分,没有Joomla文档建议的php呈现。仍然不起作用。我已经尽我所能尝试过了。