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:
- Login as administrator.
- Goto Content - Article Manager.
- Click "Options" on the menu (the one second from the right). You should see a popup screen titled "Article Manager Options".
- Click the tab "Text Filters" (also second one from the right).
- For all Filter Groups, the default is "Black List". For the respective Filter Groups, change the Filter Type from "Black List" to "No Filtering".
- 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".
- Don't forget to click "Save & Close"
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
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!
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
Can use DirectPHP with Ajax code as well?
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
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
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
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
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
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
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
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
Did you use the default visual editor mode or the HTML mode?
Regards,
/kksou
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
#
"Parse error: syntax error, unexpected ';' in /home/a7576657/public_html/plugins/content/DirectP HP/DirectPHP.php(58) : eval()'d code on line 6
"
If you can help would be nice
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
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
RSS feed for comments to this post