How to enter HTML tags, javascript and PHP codes in Joomla 1.6 and 1.7?

Note: The following applies to Joomla 1.6 / Joomla 1.7 and above only.

By default, the Joomla editor strips away any HTML tags, javascript and PHP codes in a Joomla article.

If you are using DirectPHP, you can use the following to enter PHP codes in your article:

  1. Login as administrator.
  2.  

  3. Goto Content - Article Manager.
  4.  

  5. Click "Options" on the menu (the one second from the right). You should see a popup screen titled "Article Manager Options".
  6.  

  7. Click the tab "Text Filters" (also second one from the right).
  8.  

  9. For all Filter Groups, the default is "Black List". For the respective Filter Groups, change the Filter Type from "Black List" to "No Filtering".
  10.  

  11. For example, if you are only administrator, change the Filter Type of the Super Users to "No Filtering". Leave all other remain as "Black List".
  12.  

  13. Don't forget to click "Save & Close"
  14.  

That's it! You should now be able to enter PHP codes in your Joomla article.

Note: The above applies to Joomla 1.6 / 1.7 and above only.

Comments   

+1 # Holger 2012-03-03 01:40
In Version 2.5.1 I reached the settings simply by using the configuration. There you should find the "Text filter" on the last tab.
Reply | Reply with quote | Quote
0 # Sonyks 2012-03-10 01:19
Thanks.. i was stuck in 2.5 joomla trying to find out text filtering.
Reply | Reply with quote | Quote
0 # Ingrid Wood 2012-05-24 12:59
kksou,

I installed your DirectPHP plugin, and it works like a charm - thanks!

You may want to add an instruction to turn off any WYSIWYG editor; set the global config to Editor - None.

I mucked a bit around, thinking I still lost my PHP code.

thanks!
Reply | Reply with quote | Quote
0 # kksou 2012-05-28 07:37
Hi Ingrid,

Thanks for the tips! This will definitely help some of the people who have trouble getting this to work.

I found that depending on what you're trying to run using DirectPHP, for simple PHP statements, the default WYSIWYG editor will work just fine.

I've tried to make it work with the WYSIWYG editor because I think there are quite a number of people who feel more comfortable with the WYSIWYG editor (as opposed to the HTML mode).

In any case, if people find that the WYSIWYG editor does not work, they can always switch to the HTML mode to see if it works.

Thanks and Regards,
/kksou
Reply | Reply with quote | Quote
0 # papwilly 2012-06-02 10:06
Hi Kksou,

Can use DirectPHP with Ajax code as well?
Reply | Reply with quote | Quote
0 # kksou 2012-06-03 18:54
Hi,

First, let me emphasize again that I wrote this plugin so that I can embed PHP codes easily within a Joomla article. I thought this might be useful to others, so I decide to share this plugin with the rest on joomla.org.

I use DirectPHP to embed simple PHP commands. For complicated PHP commands, I will write Joomla plugins or modules - it's more efficient and easier to debug.

For Ajax, you need 2 portions - the client part and the server part. You can code the client part using DirectPHP inside your Joomla article. But for the server side, it's recommended that you code it using straight .PHP file.

Regards,
/kksou
Reply | Reply with quote | Quote
0 # pit 2012-06-25 00:41
Hi,

Thank you very much for this plugin. I get some strange error

Parse error: syntax error, unexpected $end in /users/suryoye/www/joomla/plugins/content/DirectPH P/DirectPHP.php(58) : eval()'d code on line 3

can you tell me what to do?

use joomla 2.5.4

regards,
pit
Reply | Reply with quote | Quote
0 # kksou 2012-06-25 00:46
Hi,

Most likely there's some error in the PHP codes you're trying to run.

Can you list here the codes you're trying to run (if it's not too long)?

If it's too long, would suggest you copy the entire PHP codes into a standalone PHP file and use include() or require() to load the file. Then make sure you set error_display in your PHP.ini file and you will be able to see the error messages.

DirectPHP uses the standard PHP eval() function. It's almost impossible to debug as the error messages displayed does not tell you anything.

Regards,
/kksou
Reply | Reply with quote | Quote
0 # pit 2012-06-25 01:19
Thank you for your help.

I insert the code into a txt file and uploadet. I hope you will find the strange code.

here is the file http://www.2shared.com/document/Pdse7uIo/php.html

regards
pit
Reply | Reply with quote | Quote
0 # kksou 2012-06-26 09:36
Hi,

Please refer to the following article:
Using DirectPHP - intermixing PHP with HTML commands
http://www.kksou.com/php-gtk2/Joomla/Using-DirectPHP-intermixing-PHP-with-HTML-commands.php

Also, please take a look at your PHP file. You are trying to load a standalone PHP file with its own header into a Joomla article. It won't work.

A Joomla article has its own Joomla header. Your PHP file is going to mess up the Joomla page.

DirectPHP, or any other plugin that allows you to run PHP, is for inserting simple PHP codes into a Joomla article. If you want to run complicated PHP commands, would suggest you do it using a module or component, as oppose to loading it from within an article.

Regards,
/kksou
Reply | Reply with quote | Quote
0 # Ingrid Wood 2012-06-26 09:46
I got it to work, see: http://greencitiescoalition.net/index.php/members

The pbm I had in my code was that I was disconnecting from the server too soon. Let me know if you want the code.

-Ingrid
Reply | Reply with quote | Quote
0 # PeterWinkels 2012-07-05 02:27
Hello,

I've installed directPHP. It works quite well, but I don't get any php Error-messages. It's a problem of Joomla in general (then: where it's possible to switch on showing error messages) or it's a problem of directPHP?

Thanks * Peter
Reply | Reply with quote | Quote
0 # kksou 2012-07-07 06:21
Hi,

Please google for "php.ini turn on error reporting" and you will see tons of pages that show you how to turn on the display of error messages in PHP.

However, please note that DirectPHP uses the standard PHP eval() function. If you have played with this function before, you will know that the error messages returned by eval() is not useful at all. It's almost impossible to debug based on the error messages returned by eval().

As such, if you really want to debug errors in your PHP statements, you might want to copy and paste your entire PHP scripts into a standalone .PHP file, and use DirectPHP to do a require_once() or include() to include that .PHP file. In this way, you will find that the error messages (if there's any) will be a lot more meaningful.

Once your scripts runs ok in the standalone file, you can then copy and paste the entire script back into DirectPHP.

Regards,
/kksou
Reply | Reply with quote | Quote
0 # Upul 2012-07-22 20:34
Hi I'm working with xampp 1.7 and joomla 1.7 with tinymce editor. I have installed DirectPhp but it doesn' show the php content. It shows only "Now is:" in the sample code Now is: . I have already set text filtering to No filtering. Please help me.
Reply | Reply with quote | Quote
0 # kksou 2012-07-23 04:10
Hi,

Did you use the default visual editor mode or the HTML mode?

Regards,
/kksou
Reply | Reply with quote | Quote
0 # konika 2012-10-29 04:44
Hi, Thanks a lot for the plugin, I had used it before and it worked fine on older versions of Joomla. but recently I installed Joomla ver 2.5 and then saw that PhP scripts were not working.
So I tried to install directphp for version 2.5, and got the error that there is already a folder with directphp name in plugins/content folder. So I removed the old one and reinstalled the downloaded direct Php plugin. My problem is that anything within the PHP script is not working at all- with no error I guess. Here is the sample script


Hope you can help me find the problem.Thanks
Reply | Reply with quote | Quote
0 # konika 2012-10-29 04:46
''
Reply | Reply with quote | Quote
0 # konika 2012-10-29 04:47
I guess php script are not shown here - my last try with #
#
Reply | Reply with quote | Quote
0 # konika 2012-10-29 04:49
please delete my previous post, I was able to enable directphp and it worked. Thanks a lot
Reply | Reply with quote | Quote
0 # Lens 2012-12-14 10:41
Have problem..
"Parse error: syntax error, unexpected ';' in /home/a7576657/public_html/plugins/content/DirectP HP/DirectPHP.php(58) : eval()'d code on line 6
"

:oops:

If you can help would be nice
Reply | Reply with quote | Quote
0 # sheerkoshan 2013-07-15 15:46
Dear friend
I'm using joomla2.5.8 and there is no "text filters" in article option tabs.

what should i do now?
I've installed and enabled the plugin but I can't get it worked
Reply | Reply with quote | Quote
0 # kksou 2013-07-16 00:58
Hi,

1) Login as adminitrator

2) Go to Site - Global Configuration.

3) Click the rightmost tab is "Text Filters"

This is the one you're looking for.

Please give it a try and let me know if everything's ok now.

Regards,
/kksou
Reply | Reply with quote | Quote

Add comment


Security code
Refresh