简体   繁体   中英

Can I insert executable PHP code into Joomla custom HTML module?

if you open this Joomla website you can easy understand what I have to do: http://lnx.erusma.org

As you can see at the bottom of the page there is a Custome HTML Joomla module named Get in touch

This custom HTML module contains this simple HTML code that show an e-mail form:

<form>
    <input id="name" title="name" type="text" placeholder="Your name" size="23" style="width:94%" />
    <input id="email" title="email" type="text" placeholder="Your email" size="23" style="width:94%" /> <br />
    <input id="subject" title="subject" type="text" placeholder="Subject" size="51" style="width:94%" /><br />
    <textarea id="message" cols="33" style="width:94%" placeholder="Message"></textarea>
    <a style="display:inline-block;background:#fff;border: 1px solid #E7E7E7;border-bottom: 2px solid #93B62A;padding:8px 12px;" href="#" style="float: left;">Submit</a>
</form>

I have inserted this HTML code by the JCE Joomla Text Editor .

Now I want to do the following thing: I have to attach to this form a php script that sends an email to a certain address (sending the name of the sender, the e-mail of the senter, the subject o the message and the text of the message)

Can I put this executable PHP script into the JCE Joomla Text Editor ? It seems to me that have some problem to do it but I don't know if am I missing something.

Tnx

Andrea

You can use an module to do your job and not a html form via JCE Joomla Text Editor.

But if you want keep like that then you must replce <form> with below code

<form action='index.php?option=com_GetInTouch' method="get">

and after that you must develop your own custom joomla component named GetInTouch . Read this artiche about how can create custome component for joomla 2.5 http://docs.joomla.org/J2.5:Developing_a_MVC_Component/Developing_a_Basic_Component

JCE Editor will strip non-HTML code when saving your Custom HTML Module.

You can use a plugin such as Sourcerer or similar and include your code within {source}{/source} tags so that the code is preserved.

Sourcerer: http://extensions.joomla.org/extensions/core-enhancements/coding-a-scripts-integration/custom-code-in-content/5051

You can use the free version of sourcerer.

This article explain how to use this plugin https://www.joomlashack.com/blog/joomla/use-javascript-or-php-in-a-joomla-article/#!/ccomment-comment=1408

Step #1. Download the Sourcerer Plugin Go to the Joomla Extensions Directory and find Sourcerer. 在此处输入图片说明

Step #2. Upload and Install Sourcerer In the Administrator area of your Joomla site, click Extensions > Manage. You will be taken to the Extensions: Install administrative page: go to extensions manage

Click Upload Package File tab. Click Or browse for file green button and find the Sourcerer plugin installation file on your hard drive. Click twice on the plugin package file name to start its installation. Go to Extensions > Plugins. and make sure the following plugins are enabled: Button - Regular Labs - Sourcerer System - Regular Labs - Sourcerer

Step #3. Add JavaScript and PHP codes to a Joomla Article go to articles add new article

Click Content > Articles > Add New Article. Click on the new Code icon at the TinyMCE editor toolbar. 在此处输入图片说明

You will see Insert Code popup.

在此处输入图片说明

Write your code directly into the box. Make sure that code has the normal opening and closing tags.

在此处输入图片说明

When you're done, click Insert in the top-left corner. click the insert button

Click Save or Save & Close. Now check this article at your site frontend. You should see your JavaScript and PHP code snippets at work. 在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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