If you are using DirectPHP, you can use the following to enter PHP codes in your article:
- Login as administrator.
- Goto Global Configuration.
- Click the tab "Text Filters" (first 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 2.5 and above only.
Comments
It does work for me, I have joomla 2.5.1, and did set up as above.
- plug in is published;
- text filters in global config sets up to "no filter";
after typing into the article:
the editor uses html comments like :
Is direct php working for 2.5.1 ? or I forgot to do something else?
Thank you
I forgot "NOT" in my previous comment.
It does NOT work for me with joomla 2.5.1.
Looking forward to hearing from you guys.
I figured out that you cannot type your code into the html source editor.
copy and paste the php code straight into the editor and it works.
Yes, you should enter the code in the WYSIWYG editor. DO NOT click the "HTML" button and enter the code in the html source editor.
Regards,
/kksou
Please refer to: How to display and process forms in a Joomla article using DirectPHP?
www.kksou.com/php-gtk2/Joomla/How-to-display-and-process-forms-in-a-Joomla-article-using-DirectPHP.php
Regards,
/kksou
I suppose you are referring to using DirectPHP.
This is a plugin. As name suggests, it's for use within a Joomla article.
So try entering
echo "test123";
in an article.
You should be able to see "test123" somewhere in your article.
Once you see that it works, you can slowly add more complicated PHP commands within your article.
Regards,
/kksou
Have you tried using multi-lines? It should work.
If not, what's the error messages that you see on the screen?
Regards,
/kksou
Is multi-lines a settings?
Are you saying that if you enter:
echo 'test123';
It works ok.
But if you enter:
echo 'this is line1';
echo 'this is line2';
Can you show me the URL displaying the 2 lines above, i.e.
echo 'this is line1';
echo 'this is line2';
It doesn't work?
Also, what are the PHP commands that you are trying to run?
Regards,
/kksou
Nice little tool but the \ of "\n" for newline is being stripped out of my code. I've turned filtering off. Anything else I can do?
Thanks, Shaun
If you take a look at the source code, there's no lines that strip the \n. So guess it's by the Joomla editor.
You might want to try some other Joomla editor that allows direct editing in raw HTML.
By the way, why would you need the \n? They are "transparent" in an HTML page, isn't it?
Regards,
/kksou
Portfirmaet.dk Anmeldelser
Should it work with this module/plugin?
If you know PHP well and know what you're doing, you should be able to do it.
There's no magic in DirectPHP. The plugin simply grabs all the PHP statements that you've written within the PHP tag and pumped them through the standard PHP eval() function.
Just remember that you are running DirectPHP within the Joomla article and Joomla framework. What this means is that if you connect the DB to another mysql database, you MUST make sure that you connect the DB back to the joomla database at the end of the DirectPHP statement.
Otherwise, you will find that your entire Joomla DB connection is gone and your Joomla page will not render properly.
Regards,
/kksou
I'm pasting my code in a standart article with the standart editor, and the output is just the code as text.
The problem is solved. Apparently the start and end tags is supposed to be on the same line as the commands.
It does not need to be all on the same line.
1) Please use the WYSIWYG mode (not the HTML mode).
2) Instead of , use shift-. will generate . shift- will generate
Internally, DirectPHP will convert all and to \n.
Please try the multiple lines one more time and let me know if it works.
Regards,
/kksou
it's not showing form in articles
1) Please try a simple PHP statement first e.g. echo "test 123";
Does it work?
2) If (1) works, then the problem is with your PHP statements producing the form.
What's the error messages that you see on the screen? (You might need to turn on error_display in php.ini.)
By the way, 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
You might also want to take a look at this article: How to display and process forms in a Joomla article using DirectPHP?
Link here: http://www.kksou.com/php-gtk2/Joomla/How-to-display-and-process-forms-in-a-Joomla-article-using-DirectPHP.php
Regards,
/kksou
Parse error: syntax error, unexpected '
That's strange. If you take a look at the source code, it doesn't detect the string "FROM".
It might be due to your other plugins.
Alternatively, you can do something like
$a = 'FROM";
Then every time you need to use "FROM", you can use $a.
Regards,
/kksou
I've just installed this in 2.5. activated and 'no filtered' the superuser but code only seems to work when logged into the frontend as superuser.It just displays the code when not logged it. put 'no filter' on public (temporarily) and it still just displays the code and doesn't run.
I'm using JCE editor if there's some setting within this addon i need to alter
Have i missed something
Quoting kksou:
Turns out it's a theme problem. I think they theme is trying to stop SQL injections and it's messing with your plug-in.
You're plug-in is quite perfect for many of my uses. I use custom PHP and SQL through modules instead of components every time I have an idea. Probably should still learn.
Awesome plug-in still! ^_^
Please don't try with long codes first. Try something simple like
echo "test123";
and see if it works first.
Regards,
/kksou
Since the one-line version works, this is what you can try.
1) When you enter multiple lines, if you are using the default Joomla editor, try to use shift-enter instead of enter between lines. Enter will generate [p] and [/p]. Shift-enter will generate [br]
2) Try 2 lines first:
echo 'this is line 1';
echo 'this is line 2';
3) If (2) works, you can slowly add more lines and replace with your codes. Do it bit by bit, so that it's easier to debug if there's anything wrong.
Of course, if you're ok with the one-line version to include your other .php files, that's fine too!
Regards,
/kksou
I have 2 questions. First of all, I have downloaded the DirectPhP for Joomla 2.5 and set it up mentioned in this article. I'm new to Joomla. I don't know where should I put DirectPhp.php file to see the effects. In other words, I want complete instructions on printing "hello world" on my website using DirectPhp.
Secondly, I have a new website built on Asp.net which requires Single sign on from my Joomla 2.5 website. So, when a person has logged into my Joomla website, a menu item should appear which will direct him to my asp.net website along with passing username in encrypted form. I'm really struggling with how to do this and need solution for this ASAP. Please, I would highly appreciate your suggestions. Thanks
1) For your first question, DirectPHP is a plugin. As the name suggests, a plugin is for use within a Joomla article. So to use DirectPHP, you go to the Article Manager, create a new article, and plugin in your PHP codes within the article.
2) I'm not familar with .net. So it's difficult for me to help you here. Would suggest you post your question in the official joomla.org forum. Someone might be able to help you there.
By the way, if you're thinking of using DirectPHP to resolve your second question, then this might not be the right tool. As mentioned in (1), DirectPHP is for use within a Joomla article. For your situation, you should be looking at creating your own module or plugin.
Regards,
/kksou
Thanks for your reply. I appreciate it. You don't have to know anything about .Net. Just that I have a session variable "username" in joomla 2.5 that I need to pass as parameter to www.hapw.com/PLW/Default.aspx?username=value. I want this to be done with a menu item in joomla 2.5 that will contain hyperlink to the .Net website. The thing I don't understand is that even if I create a new menu item, where should I insert the underlying php code to get my session variable value and add append to the above query string. Thanks.
Regards,
Syed
Not sure whether it's the plugin or some php set up issue.
I'm on Joomla 2.5.8.
Plugin is enabled, no filtering for superuser.
All I want to do is to put a copyright date using php date function but it doesn't work.
When I try in WYSISYG
echo "test123";
What appears on the screen is
echo "test123";
Any ideas what could be wrong?
Thanks,
Karen
Did you put the php tag:
[?php echo "test123;" ?]
note: please replace square bracket above with angle brackets.
Regards,
/kksou
it didnt work for me when i used capital letters in (
You need to give people more clues in order to know where might be the problem e.g.
1) What's not working?
2) Are there error messages that you see? If yes, what are the error messages?
3) Any other things that you see on the screen? (e.g. your PHP codes)
4) Are the code still there when you edit the article?
Regards,
/kksou
I had missed out the < > but when I put replaced the square brackets with angle brackets I received the following error:
Parse error: syntax error, unexpected $end, expecting ',' or ';' in /home/XXXXXX/public_html/plugins/content/DirectPHP /DirectPHP.php(58) : eval()'d code on line 1
Any other suggestions?
Cheers,
Karen
Sorry, my typo.
It should be:
[?php echo "test123"; ?]
note: please replace square bracket above with angle brackets.
Please give it a try one more time and let me know if it works.
Regards,
/kksou
[?php echo "blah"; ?]
all is well.
If I get "fancy" like
[?php
$x="blah";
echo $x;
?]
Nothing happens.
Please advise?
Can you please try:
[?php $x="blah"; echo $x;?]
and see if it works?
Regards,
/kksou
Sorry. Have only learned English. Would you mind to write your question in English?
Regards,
/kksou
site a local store in India i need to change Rs symbol to rupee symbol they i have java-script http://cdn.webrupee.com/js which convert all Rs or RS to that symbol plz help me how to add the script to site r any other method. my site is www.nalam.in(under development)mail me so i can send username-password for site plzzz reply back...
If you look at the source code, this plugin simply grabs all your PHP codes and pump them into the standard PHP eval() function.
The PHP eval() function is not that smart to differentiate between simple or advanced plugin. Any valid PHP code that can be processed by eval() can also be processed by DirectPHP.
Regards,
/kksou
how i can override k2 components which convert to the list from to menu tab.
You cannot do this with DirectPHP. DirectPHP is a content plugin. It's supposed to be used within a Joomla article.
You need to change the source code of the k2 components.
Regards,
/kksou
how can i edit normal html or php form to joomla 2.5
I'm using DirectPHP on my Joomla3 site without any problem.
Have you tried other editors and see if it works?
If possible, try setup a fresh install of Joomla3 somewhere on your site and then DirectPHP. This will allow you to see if it works on your machine at all, or if it's conflicts with your other plugins.
Regards,
/kksou
PHP training in Chennai
cam a cam.
cam a cam.
for example, I want to create a php script that if it is user A that access the script it will echo "apple", and if it is user B it will echo "orange"
thanks in advance
bogi.imtelkom.ac.id
DirectPHP is not used for such a purpose.
For your case, you might need to develop your own plugins and incorporate those PHP codes right inside your plugin, instead of through another layer of content plugins such as DirectPHP or any others.
For user sessions, you can google for "PHP sessions tutorial" and there will be many resources and sample codes for your use.
Regards,
/kksou
Today's date (according to this web server) is
It produces the following parsing error:
Parse error: syntax error, unexpected '
Single line works OK with TinyMCE and multiline works if I use CodeMirror editor. Joomla 2.5.11, MySQL 5.0
[?php
echo date('l, F jS Y.');
?]
Any advice (any more info needed)?
That's strange. It should work.
I couldn't know the problem without further info.
Are you ok with mysql? If yes, can you go to the backend mysql of your joomla, and locate the record of this article in the table jos_content.
Please email me the entire content of the 2 fields: introtext and fulltext - this should give me enough clue to know where the problem is.
Regards,
/kksou
I installed the plugin and set settings: to "no filter", plugin is activated and i put simple code in to wysiswyg (tinymce) and get the hole code as a plain text:
Now is:
and I get this code displayed on the frontpage.
If you see the entire code displayed, it means the code has not been processed at all (i.e. DirectPHP is not running).
If your plugin is enabled, it could mean that it's conflicts with some other plugins.
To only way to ascertain this is to install a fresh install of Joomla somewhere on your site and then install just the DirectPHP plugin. This will allow you to see if DirectPHP run on your server at all.
Regards,
/kksou
PHP training in Chennai
I will use directPHP on my joomla 3.1.5 installation. If I use the following php () in an article - it works. But if I take it in an own module it doesn´t work. I use directPHP in my joomla 2.5.x in an own module too and there it works. Any help? thx
hehe, so often to me
What have I done wrong?
I am using Joomla 3.1.5.
I downloaded your zip file, used Extension Manager to install it,enabled DirectPHP in the Plugin Manager and checked that the Super User Filter Type was set to No Filtering.
I then opened one of my articles and hit the Toggle Editor button and added a separate line with on it. On saving the article, TinyMCE had put comment braces around my PHP code.
Try to enter the code from the backend Article Manager and see if it works.
Also, when you enter the PHP code in the Article Manager, please use the default WYSIWYG mode (as oppose to the HTML mode).
Please enter something simple first for testing e.g. echo 'test123';
If it works, then you can start entering more lines. It's difficult to debug in this mode (the PHP codes are run using PHP's standard eval() function). So try entering a couple of lines at a time.
Regards,
/kksou
Found it. You don't go into the Editor, but do it on the WYSIWYG page.
No need to reply now, thanks.
I found the answer in one of your other posts above.
I'm using Joomla 3.x.
Thanks
RSS feed for comments to this post