DirectPHP plugin |
| Written by kksou | |||||||
| Monday, 24 March 2008 | |||||||
This plugin allows direct embedding of PHP commands right inside Joomla content page for dynamic contents. Available for both Joomla 1.0.x and native 1.5.x! Important: If you're using Joomla 1.5.8, please refer to the article: Table of Contents
Key Features
<?php php_commands... ?> Now is: <?php echo date('Y-m-d H:i:s');?>
<?php
require_once('fullpath/your_lib.php');
your_php_func();
?>
Latest version Updated: April 8, 2009 DirectPHP for Joomla 1.0.x: DirectPHP_v1.06 DirectPHP for Joomla 1.5.x: DirectPHP_v1.56 Added one more parameter "Using No Editor". If you're not using any editor when editing content articles, select 'yes' for this parameter. This will allow you to freely use any HTML tags (such as <br /> or <p>). BackgroundI've recently redesigned this website using Joomla. As you can see, there are more than 450 PHP-GTK sample codes. It's just too much a hassle to include each sample code into every article. Isn't it nice if I could do a simple echo "<pre>".htmlentities('filename.php')."</pre>";
to automatically include the respective sample code? I've tried two other plugins: Jumi and RunPHP .
So I decided to develop my own plugin, and the result is this plugin DirectPHP. How to install (Joomla 1.0.x)
Current date and time is: <?php echo date('Y-m-d H:i:s');?>
To customize the block list (Joomla 1.0.x)
How to install (Joomla 1.5.x)
Current date and time is: <?php echo date('Y-m-d H:i:s');?>
To customize the block list (Joomla 1.5.x)
ExamplesHere are some examples:
Now is: <?php echo date('l j D, Y H:i:s');?>
<?php
for ($i=0; $i<10; ++$i) {
echo "$i: ".$i*$i,"<br>";
}
?>
<?php
require_once('/fullpath/your_php_library.php');
display_image('image123.jpg');
?>
<?php global $a;
$a = 10;?>
This is a test. variable $a = <?php echo $a;?>
<?php
function f1() {
global $a;
return $a*2;
}
$b = f1($a);
?>
You can access variable $a from within the function with global.
variable $b = <?php echo $b;?>
<?php echo "<table border=4$gt;"; echo "<tr><td>a11</td><td>a12</td></tr>"; echo "<tr><td>a11</td><td>a12</td></tr>"; echo "</table>"; ?> For Joomla 1.0: <?php
global $my;
if ($my->id==0) {
// non-registered members
print "Please register or login.";
} else {
// registered members
print "Contents for registered members.";
}
?>
For Joomla 1.5: <?php
$user =& JFactory::getUser();
if ($user->id==0) {
// non-registered members
print "Please register or login.";
} else {
// registered members
print "Contents for registered members.";
}
?>
Important Note: Blocking of PHP commandsBy default, I've blocked some of the potentially "risky" commands, e.g. system, fopen, unlink, rmdir, etc. You can view the entire list of PHP commands that are blocked in the plugin's property page. In there, you can also add, edit or delete this list of commands to suit your needs. If you need to use any of these commands (e.g. mkdir) from within the content page, put them in one of the library files on your server, do a If you insist, you may choose to turn off the blocking in the property page. However, I would strongly advise that you do so only if you're the only one maintaining your Joomla site. If you're opening up the adding and editing of content pages to the public, DO NOT turn off the blocking. It's too dangerous. DisclaimerDirectPHP is a simple, yet flexible and powerful plugin. I'm using it on this website. I'm sharing with you here because I think it will be very useful to some of you. Your use of this plugin is at your own risk. kksou.com makes no warranties or representations, express or implied, as to the functionality or usefulness of this plugin. kksou.com disclaims all warranties, express or implied, including without limitation warranties of merchantability and fitness for a particular purpose. kksou.com disclaims liability for any direct, indirect, incidental, consequential, special, exemplary, punitive or other damages, or lost profits, that may result, directly or indirectly, from your use of this plugin, including without limitation any damage to computer systems, hardware or software, loss of data, or any other performance failures, or any errors, bugs, viruses or other defects that result from or are associated with use of this plugin. Be a SponsorIf you find this plugin useful, Secure Payments by PayPal. DownloadNote: To upgrade to the newer version, simply uninstall the old version and install the new version of the plugin.Version History
In TinyMCE Editor, when you press Enter, internally it's stored as a <p>. If you press shift-Enter, internally it's stored as <br>. In v1.00, if the user presses Enter after "<?php", the php script will not be captured. I only preg_matched for <br>. Overlooked the case for <p>. Bug has been fixed. In some of the editors, tabs is internally stored as &160;. If you're using tabs for code indentation, please download this update. Encapsulate all functions used by DirectPHP within a class so that you can use DirectPHP with some other plugins such as the "DirectPHP for Category Description" plugin. Now supports both PHP5 and PHP4. Thanks to Salvatore who informed me about some "mysterious" double-byte characters that get inserted into the DirectPHP code by the content editor of some of the non-English Joomla. These double-byte characters will cause error when processing the PHP commands with eval(). Have fixed this in this version. User reviews Average user ratings: 4.0 (from 82 users) Note: You have to be a registered member to leave a comment. Free registration here. |
|||||||
| < Prev |
|---|
Joomla 1.0 Articles
- How to create a module with DirectPHP plugin?
- How to include modules in Content item?
- How to include modules in Section/Content Description
- How to include PHP commands in Section/Content Description
- How to make plugins process Section/Category descriptions
- Include Code Listing plugin - More Tips and Techniques
- How to have DirectPHP plugin process RSS feed?
- How to have the plugins processed when genrating PDF documents of content items?
- How to have DirectPHP commands processed in Joomla search?
Joomla 1.5 Articles
- How to create a module with DirectPHP plugin?
- How to include modules in Content item?
- How to include modules in Section/Content Description
- How to include PHP commands in Section/Content Description
- How to make plugins process Section/Category descriptions
- Include Code Listing plugin - More Tips and Techniques
- How to have DirectPHP plugin process RSS feed?
- How to have the plugins processed when genrating PDF documents of content items?
- How to have DirectPHP commands processed in Joomla search?
Joomla Plugins
Joomla Components
Joomla Gadgets
- Google Image Search
- Google News Search
- Wikipedia Search
- Google Book Search
- Google Video Search
- Google Currency Converter - AJAX version
- Yahoo Currency Converter - AJAX version
- Yahoo Stock Quote (AJAX module version)
- Yahoo Stock Quote (AJAX component/ module version)
- googleSearch_cse component
- googleSearch_cse module
- googleMaps plugin








4.0 (from 82 users)
March 26, 2008 10:46pm
I would kill for this to work - but everytime I save it, then re-edit the content item, the php has disappeared. I'm using fck2 for an editor...
March 26, 2008 11:01pm
Hi Rod,
I don't use fck2. The plugin has been tested on the default TinyMCE WYSIWYG Editor.
But I'll install fck2 and test it out. Will get back to you as soon as I find out where's the problem.
Regards,
/kksou
March 27, 2008 1:36am
Hi Rod,
I supposed you're referring to JCK. The website said it was formerly called was joomlafck2.
I installed the editor. True enough. Entering and saving the code was ok. But when you tried to reload the content, the php code "disappeared".
I probed around and found a couple of things:
1) The code is still there in the mysql db. If you go straight into jos_content, you can see the code there.
2) Interestingly, if you do a view source, the code is also there! It's just not shown.
This leads me to realize that the code was being parsed by one of its javascript functions. That's why you can see it in view source, but the code is not displayed.
I believe the function is contained in the file:
mambots/editors/joomlafck2/editor/js/fckeditorcode_gecko.js
However, the author has "encrypted", or obfuscated, the code. So there's no easy way to change the code. I would suggest you contact the author to see if he's willing to add one more parameter so that user's can choose whether to view or not view the PHP codes.
As a "quick fix", you can actually comment out the code that make the PHP code disappear.
Open up the file: mambots/editors/joomlafck2.php. Scroll to the bottom. You will see the following statements:
<pre>
return <<<EOD
<textarea name="$hiddenField" id="$hiddenField" cols="$col" rows="$row" style="width:{$WidthCSS}; height:{$HeightCSS};">$content</textarea>
<script type="text/javascript">
/*
var oFCKeditor = new FCKeditor('$hiddenField');
oFCKeditor.BasePath = '$mosConfig_live_site/mambots/editors/joomlafck2/' ;
oFCKeditor.Width = '$wwidth' ;
oFCKeditor.Height = '$hheight' ;
oFCKeditor.ToolbarSet = '$toolbar' ;
oFCKeditor.Config['EditorAreaCSS'] = '$mosConfig_live_site/$content_css';
oFCKeditor.Config['StylesXmlPath']= '$mosConfig_live_site/mambots/editors/joomlafck2styles.xml.php?css_filename=$content_css' ;
oFCKeditor.Config['CustomConfigurationsPath'] = '$mosConfig_live_site/mambots/editors/joomlafck2.js.php' ;
oFCKeditor.ReplaceTextarea() ;
function InsertHTML(field, value) {
// Get the editor instance that we want to interact with.
var oEditor = FCKeditorAPI.GetInstance(field) ;
// Check the active editing mode.
if ( oEditor.EditMode == FCK_EDITMODE_WYSIWYG )
{
// Insert the desired HTML.
oEditor.InsertHtml( value ) ;
}
else
alert( 'Please switch to WYSIWYG mode.' ) ;
}
*/
</script>
<br />
<p>$buttons</p>
EOD;')
</pre>
Comment out the entire javascript code as shown above with /*...*/.
Try the editor again. You will be able to see all your PHP codes right there!
But of course, there's some problem with this approach. You will find that your editor has now become a pure HTML editor. If you need a line break, you have to manually enter a <br> or <p>.
So I guess the best is still for you to contact the author of JCK for help.
Regards,
/kksou
March 27, 2008 2:34am
hmmm just want to know if this is possible for putting a slideshow module in the front main page mosbody easy?
should be like using {loadmodule mod_fpslideshow} for having that in a content article page easy. Is this possible ?
March 27, 2008 7:52am
Yes. You can actually easily create a module or component using this plugin.
If you're using Joomla 1.0.x, go to Module Manager, click New, then scroll all the way down to the bottom. In the custom output, you can add any PHP code here. It will be processed by the DirectPHP plugin.
So if you have written some PHP/javascript library that presents a slideshow of images, just create a module as described above and publish it in one of the module position in the front main page.
As for Joomla 1.5.x, the HTML module (was Custom module in 1.0.x) is no longer processed by the content plugins. The solution is to install a module called "CustomContent" by Ian MacLennan first. Once you've installed this module, you can publish any article in any module position. In that article, you can place any PHP code there, which will be processed by the DirectPHP plugin.
I will give more details and examples of creating modules and components using the DirectPHP plugin in the next one or two days.
Regards,
/kksou
March 27, 2008 8:53am
Hi Rod,
I spent a bit more time with JCK and found a solution which seems to work.
Edit the file: mambots/editors/joomlafck2.php. Look for the function "function botEditorArea()". You will see the following 5 lines:
<pre>
$content = str_replace("<", "", $content);
$content = str_replace("&", "&", $content);
$content = str_replace(" ", " ", $content);
$content = str_replace(""", "\"", $content);
</pre>
Comment out this 5 lines altogether.
<pre>
/*$content = str_replace("<", "", $content);
$content = str_replace("&", "&", $content);
$content = str_replace(" ", " ", $content);
$content = str_replace(""", "\"", $content);*/
</pre>
Now edit an article and type in some fresh php commands (don't use the old one that you've typed before) and save it. Reload it. You should be able to see the php commands back in the editor.
I tried quite a few sample codes and they all seem to work.
Do give it a try. Hope it works on your machine too!
Regards,
/kksou
March 27, 2008 9:27am
this is a great addition to Joomla! And amazing response from kksou... thanks for your work!
Rod
March 28, 2008 2:41am
"I will give more details and examples of creating modules and components using the DirectPHP plugin in the next one or two days."
That would be great!
I will try to use this with the Slideshow component that also have a module and it would be nice to have that module on front page by article...:-)
http://extensions.joomla.org/component/option,com_mtree/task,viewlink/
link_id,1664/Itemid,35/
March 28, 2008 3:00am
What I mean is to publish it to mainpage mainbody.
Publishing the slideshow module to frontpage article!
March 28, 2008 9:08am
This is a very nice plugin, but I've run into a problem similar to Rod's. I'm using the JoomlaFCK editor (available from www.joomlafckeditor.com) with Joomla 1.5 and when editing an article that includes PHP it replaces some essential characters for the plugin to work. I tried looking in the editor's php file (plugins/editors/fckeditor.php) but couldn't find any lines similar to the ones you mention above.
Can you please take a look?
March 28, 2008 9:31am
Hi JoyMonkey,
From the filename you mentioned, looks like you're using JoomlaFCK v1. The one Rod used is v2.
Let me look around to see if ver 1 is still available for download. Will try it out and get back to you if there's any possible solution.
Regards,
/kksou
March 28, 2008 9:41am
No, it's not v1, it's a new branch of JoomlaFCK (it's a little confusing, I know). This is a new editor, but appears to be very popular.
Here is a direct link to the editor I'm using:
http://joomlacode.org/gf/download/frsrelease/6583/21437
/mod_bot_JoomlaFCKeditor2.5.1.1bVersion1.5.zip
March 28, 2008 9:41am
Hi Ssnobben,
"What I mean is to publish it to mainpage mainbody."
Sorry I misunderstood your question earlier.
Yes, it's possible. You can actually "insert" a module into a content page. But this is a Joomla "feature" and you do not really need the DirectPHP plugin to enable this.
Doing this on Joola 1.0 and Joola 1.5 is slightly different. Give me about one day. Will post the solution in the tutorial section near the top of this page.
Regards,
/kksou
March 28, 2008 1:36pm
Excellent plugin
Is there anyway to auto switch off the rss feed for any article that uses direct php - or strip the php out - at the moment the actual code shows in the feed.
March 28, 2008 4:46pm
When i do the test, only appear the text just like i put it. The plugin is enable and i'm set TinyMCE by default and i have joomla 1.5, could you please help with this...
March 29, 2008 12:15am
Hi Greivin,
If you're sure the plugin is enabled, then
1) First let's try this one more time:
now = <?php echo date('Y-m-d');?>
Please enter everything in one line (or just copy and paste into the editor). Reload the page. Did you see the php code or the time? Or did you see any error message?
2) If it still doesn't work, then may I know if yours is a fresh install of Joomla 1.5? Have you installed any other plugins? I know some plugins such as jReviews removes all modifications by other plugins. They simply load the original content straight from mysql db and rewrites the contents. So DirectPHP will not work if you have such a plugin installed.
3) As a test, you might want to try installing a fresh Joomla 1.5 into another location (it takes only about 5 minutes). Then install DirectPHP and see if it works. If it does work, then you know the problem is with one of the plugins that you have installed in your original Joomla.
Hope this helps...
Regards,
/kksou
March 29, 2008 2:28am
Hi Gp44,
Which rss generator are you using? Are you using the rss feed that comes with standard Joomla installation? If yes, I could modify that to suit your need. (But please let me know which version of Joomla are you using - J1.0.13, J1.0.15 or J1.5?)
Regards,
/kksou
March 29, 2008 3:15am
Hi JoyMonkey,
I tried all 3 versions of JoomlaFCK from
http://www.joomlafckeditor.com/index.php?option=com_content&view=category
&layout=blog&id=34&Itemid=61
All 3 versions (v2.5.1, v2.5.1.1 and v2.5.1.1b) seem to work fine. Switching between standard view and code view works fine too.
1. May I know if you're using any of these 3 versions, or an earlier version?
2. If you're using an earlier version, would you want to try the latest version and see if it works on your machine?
3. Also, may I know if the plugin is not working at all? Or only some of the php statements are not working? If it's only some, could you please show me some of these php codes that don't work? (need to know which of the characters get converted by the editor)
4. Lastly, does the simple statement:
now = <?php echo date('Y-m-d');?>
work on your machine? When you save the above statement and reload it in the editor, what did you see? Just 'now =' or any other text?
Regards,
/kksou
March 29, 2008 1:20pm
Hi got this info today:
Re: v 1.5 Interface Changes
New postby guysmiley on Sat Mar 29, 2008 7:57 pm
Note:
Code above is inaccurate. For calling modules in J1.5 use:
Code: Select all
{loadposition moduleposition
}
Example:
Code: Select all
{loadposition advert1
}
March 30, 2008 2:03am
Seems to be problem with this loadposition moduleposition
call.
Here is a topic in Joomla forum http://forum.joomla.org/viewtopic.php?f=304&t=175613&p=1253384#p1253384
March 31, 2008 5:21am
1. I'm running the latest version (v2.5.1.1b).
2. I removed JoomlaFCK and re-installed it to make sure I'm using that version.
3. I've only tried one piece of php (your example #6).
4. Trying it now...
Inserting the line "now = " into an article using JoomlaFCK's 'Source' button works fine.
However, when I try to edit that article it removes the php code entirely, leaving it as "now ="
March 31, 2008 6:49am
Hi JoyMonkey,
Thanks for the detailed description of what you've tried. Guess I know what's happening.
I followed what you did. Enter the php code in source mode. And then switch back to the editor mode. Yes, the codes are gone.
In JoomlaFCK, you have to enter those PHP code right in the editor mode (i.e. not the source mode). Try it. Just type <?php echo date('Y-m-d');?> direct into the editor and save it. It should work.
Regards,
/kksou
April 01, 2008 7:32am
I just assumed that the php code would be best entered in source mode. Thanks for clearing this up kksou! It's working perfectly now!
April 03, 2008 11:10pm
Using Joomla 1.0.13, tiny MCE editor, Mambot is published, code is entered in editor (not in HTML box) and saved.
The php code itself is displayed on the page, ie. Current date and time is:
Anything else I can try ? Thanks !!
Paul
April 08, 2008 1:15am
Please try one more time. Enter the following into editor all in one line:
Current date is: <?php echo date('Y-m-d');?>
If it still doesn't work, then one possible reason could be that you have other plugins installed that do not follow the standard rules. I know some plugins do that by overwriting whatever modifications that have been done by other plugins.
As a test, you might want to try installing a fresh of Joomla into another location (it takes only about 5 minutes). Then install DirectPHP and see if it works. If it does work, then you know the problem is with one of the plugins that you have installed in your original Joomla.
Regards,
/kksou
April 22, 2008 6:26pm
I installed directphp to a fresh joomla 1.5 install (using the installer and uploading the zip file, not unzipping and uploading as you described) and I am using the tinymce editor that is the default.
Unfortunately, whenever I enter the "<" character before php, it gets changed to "<" in the html (as does ">" get changed to something else. But when I go into the html and change it back to a "<" and ">" the whole php line i have entered simply disappears after saving - as in it is not there when I look back in the html for it.
Do you know the solution to my problem? I really hope to use your plugin!
April 22, 2008 6:26pm
Sorry for this repost - my first one had things dropped at certain points so I had to edit out quote marks that were throwing things off.
-----------
I installed directphp to a fresh joomla 1.5 install (using the installer and uploading the zip file, not unzipping and uploading as you described) and I am using the tinymce editor that is the default.
Unfortunately, whenever I enter the < character before php, it gets changed to < in the html (as does > get changed to something else. But when I go into the html and change it back to a < and > the whole php line i have entered simply disappears after saving - as in it is not there when I look back in the html for it.
Do you know the solution to my problem? I really hope to use your plugin!
April 22, 2008 6:27pm
Hi Tim ,
Yes, tinymce editor will change those < and > to some other characters. (In fact, it will change many other characters such as ' and ".)
But don't worry. My plugin will change all these back. So just go ahead and type those PHP commands in the tinymce editor. It should work just like that.
Note that if you change those htmlentities back to say '<' and '>' by directly editing the content in mysql, you will find that all your PHP commands will disappear. This is because the tinymce editor refuses to show any tags in the editor, even though all your codes are still there.
Alternatively, you might want to try installing other editors (one good one is JoomlaFCK) that allows you to easily switch between WYSIWYG mode and Source Code mode.
Regards,
/kksou
April 22, 2008 8:11pm
Thanks for your answer - it helped me narrow down what was happening.
I am working with a fresh joomla 1.5.2 install, but I did import the database from a an existing 1.0.13 site - so i guess that might not qualify as totally fresh.
Once I actually typed in the code (instead of relying upon elements of whatever was already there) things took.
It also helped greatly when I actually included the question mark in the opening php tag. Yes, I'm a php noob i guess.
Your plugin is awesome and it's so great it is 1.5 native. If you haven't already put it up on the joomla extension site, you really should. There are lots who will enjoy using it.
April 23, 2008 8:51am
Hi Kksou, I'm using JCE Editor and installed DirectPHP plugin, pasted PHP your exemple code:
now =
but nothing happens. It's possible this plugin work together with JCE Editor?
April 23, 2008 6:00pm
Hi Filipe,
1) First double-check that the plugin is published.
2) Next go to Site - Global Configuration, and set Default WYSIWYG Editor to "No WYSIWYG Editor". Now enter the following into editor all in one line:
Current date is: <?php echo date('Y-m-d');?>Reload the page. Did you see the date and time? If yes, it means DirectPHP is running ok. We can then know that the problem is with the JCE Editor.
3) I will try out the JCE Editor and see if I can find a fix.
Regards,
/kksou
May 02, 2008 2:43am
Hi Filipe,
I've installed the JCE Editor and tried it with DirectPHP. Yes, it does work.
One possible reason it didn't work on your system might be that: In JCE Editor, I see there's one [show/hide] link that let's you see the underlying HTML tags associated with the intro and fulltext.
I'll call the default view (the one with all the toolbars) the WYSIWYG mode, and the other view (with all the toolbars hidden) the source mode.
I believe you have entered the PHP commands in the source mode (the view without any of the toolbars). When you do this, when you switch back to the WYSIWYG mode, you will find that all your PHP commands are gone!
The "trick" is: you have to enter the PHP codes in the WYSIWYG mode.
Please give it a try one more time. Just copy and paste this line into the editor in the WYSIWYG mode:
Save and reload the page. The current date should be displayed.
Regards,
/kksou
May 08, 2008 12:17am
Hi kksou,
First let me thank you for this great plugin.
Almost everything I tried so far did work; maybe you can help
me with the part that didn't?
I wish to display the Users IP-Adress on my page (great for supporting
via remote connection) with following code:
Your IP:
Unfortunately nothing seems to happen.
Can you bring in some light?
Thanks in advance
Greetings from Switzerland
pfnuesu
May 08, 2008 5:38am
Thanks for getting back - it seems like the code was parsed... (with the same result as I get on my own page)
<?php echo "$REMOTE_ADDR";?>
Greetings
pfnuesu
May 08, 2008 6:04am
Hi Markus,
Try this...
<?php echo "ip = ".$_SERVER['REMOTE_ADDR'];?>
Regards,
/kksou
May 08, 2008 6:15am
(just gained 1 Star ;-) )
Guess I was too lazy in using the short form...
Works flawlessly!
Thanks,
Markus
May 18, 2008 7:11pm
I installed it and I tried your test codes and it worked flawlessly! I just need one simple script to work. It is a random code generator. I can get it to work on a non-joomla page. But it is still not working in joomla. this is all it is:
Sorry for this code comment, any thoughts?
May 18, 2008 7:40pm
I tried to leave you the code but it got stripped out. I am so frustrated.
May 18, 2008 7:50pm
Hi Rebecca,
You missed out a semicolon at the end of one of the PHP statements.
eval() is more "strict" than running php from command line. You need a semicolon at the end of every PHP statement.
Regards,
/kksou
May 18, 2008 7:50pm
kksou is my hero. thanks for the email help, the problem was solved in a matter of seconds.
May 23, 2008 1:07pm
First I would say thank you very much for this handy extension!
I'm using yvComment as a commenting extension in my Joomla site, I'm allowing guests to add comments. I want to use DirectPHP but I'm worried about the possibility of guests writing php in their comments, I've tried to write php in a comment, (tried this and also this <?php echo 'hello'; ?> ) it was just ignored by yvComment that's good news, but I need confirmation (if any) that it is safe to use DirectPHP while allowing guests to add comments. I really need both :(
A second question:
When I use the search feature in joomla, the php code is displayed in the search results! for example :
6. php test
('Uncategorised Content')
is there a way to prevent this
Thanks again for this wonderful extension!
May 23, 2008 1:19pm
your commenting system did not allow me to write this:
& lt;?php echo 'hello'; ? & gt;
on the previous comment, I added some spaces to accept it,
insert that in (tried this ...) in the previous comment
Best Regards
June 17, 2008 9:59am
Hello. Great work!!
I want to to this in a content of Joomla.
and i geti this:
Parse error: syntax error, unexpected T_STRING in C:\Program Files\xampp\htdocs\sitakis\mambots\content\DirectPHP.php(65) : eval()'d code on line 11
June 17, 2008 6:01pm
The error message usually means that you're running PHP4. However, I just tried with PHP v4.4.8. It runs ok. I supposed you're running a version earlier than PHP4.4.8...
Can you try changing line 67:
eval($this->fix_str2($phpcode));
to:
eval($phpcode2);
and see if it works?
Regards,
/kksou
August 06, 2008 6:05am
Hi I use joomla 1.54
and TinyMCE editor 2.0
(all standard)
Now I can't get it to work
when posting your Current date and time is:
and then saving,
the editor window only shows :Current date and time is:
Dunno what I am doing wrong.
I would like to use your plugin to include my phpfiles with db acces, show list out of db and forms from my former site (completely php based programming)
tnx
August 06, 2008 8:27am
Hi Faber,
When you enter the PHP codes in TinyMCE editor, make sure you enter the codes in the WYSIWYG mode.
DO NOT click the "Enter HTML Source" button and enter the codes in the HTML Source mode. All your codes will be stripped away by the editor.
Regards,
/kksou
August 06, 2008 11:45pm
I am pretty new to joomla, how do I check wether I am in wysiwyg mode ? if found extentions-plugin- Editor - TinyMCE 2.0 and there are settings:(translated from dutch)
Functionality advanced
clean code at start off
clean code at save always
don't clean HTML. no
save warning on
Gecomprim version on
but can't get it to work...
August 07, 2008 12:16am
oh forgot, the html button is not clicked...
August 18, 2008 3:15pm
I downloaded and installed this plugin into Joomla! 1.5.6 today. Joomla! was installed with the default data and I simply replaced the contents of the Stick to the Code! article with
August 18, 2008 3:35pm
I downloaded and installed this plugin into Joomla! 1.5.6 today. Joomla! was installed with the default data and I simply replaced the contents of the Stick to the Code! article with
. After I refreshed the Frontpage, I could see that the phpinfo() was rendered properly, albeit in very small type. There were other issues, however.
The other text on my Frontpage was also somehow affected. It was smaller than before I changed the article. It also seems that all the DIV's on the page also now have a border. Maybe my first trial should have been simpler?!?
August 18, 2008 4:09pm
My last post should have showed that the php code I was executing was simply phpinfo(); inside standard php open/close tags.
I tried the same the thing with jumi and it produced the same results as DirectPHP. So I guess this may just have been a bed one to try. Having said this, I do have some php code that renders tables and other graphics that I want to try. I'll let you know how it goes.
August 18, 2008 4:35pm
After further review, I've concluded that my test was unfair. Since phpinfo() writes a complete html file, it is not fair to expect that my page would render correctly given the test that I did. A more appropriate application for what I wanted was to use the wrapper module. Having said this, I do see a lot of value with this plugin. I think that DirectPHP and jumi (and DirectPHP with the Custom Content module) all have value. I'll probably end up using some mix of the two (three).
September 01, 2008 1:02am
Hi!This is a very interesting work and just what I needed!
The problem is that I'm getting a parse error just like iochrist above. I tried the change you suggested changing the code to eval($phpcode2) but it didn't work.
I use PHP5.What can I do?I really have to make it work!
Thanks anyway!
September 01, 2008 3:23am
If you're using PHP5, and you have "Parse error", it usually means there's some syntax error in your PHP codes.
First, you need to make sure that DirectPHP works on your machine. Try the following:
Does it work? Did you see the date?
If you see the date, it means DirectPHP works. So the next thing is to debug your PHP codes. As I've mentioned before, debugging PHP codes in eval() statement is extremely tough. So I usually test the codes on a standalone .php page. Once it works, I then copy and paste into the content item page.
Hope this helps.
Regards,
/kksou
September 02, 2008 5:49am
thanks but it didn't work..I just see exactly what I wrote..the php code..now what?
September 02, 2008 8:40am
Hi kksou, I read the help you were giving folks who lost their scripts upon saving content edited in joomlafck. My problem is slightly similar. I wanted to test an onload eventhandler and I put in body tags (I had jscript as well). After saving, both the body tags and the scripts were gone from sight, but both are still in there somewhere and causing havoc on my site.
joomlafck 2.5.1 ver 1.5
September 03, 2008 4:19am
Brilliant! Just updated to Joomla 1.5 and I wanted something to replace {kl_php}. This did it perfectly. Like some others here I had problems with code not showing in the editor. This is because I made a mistake with my update query when converting from {kl_php} to DirectPHP.
The correct mySQL syntax is:
update `jos_content` set `introtext` = replace(`introtext`,'{kl_php} ','<?php ');
update `jos_content` set `introtext` = replace(`introtext`,'{/kl_php}',' ?>');
update `jos_content` set `fulltext` = replace(`fulltext`,'{kl_php} ','<?php ');
update `jos_content` set `fulltext` = replace(`fulltext`,'{/kl_php}',' ?>');
I hope this helps anyone else having problems with the conversion.
Many thanks for this plugin,
Derek
October 11, 2008 7:23am
Hi kksou,
Sorry for my english langage, cause I'm french...
I already use DirectPHP on the content of my Joomla websites and it works very well.
Now, I would like to use it on a module named yoo_scroller for joomla 1.5, but it doesn't works.
Could you try it and give me a solution, please ?
Thanks for your answer,
- Manuphi
October 11, 2008 8:00am
I just want to precise my problem :
if I want to post an article written with php language in a module it semms that it doesn't work.
Or I made a mistake but I can't see where ?
Thanks for your answer,
- Manuphi
December 13, 2008 12:57pm
hello the download link is not working
January 21, 2009 6:21am
Hello, it would be nice if - at least optional - the editor could enter the php code in html view also. Currently I have to "transfer" pure mixed html+php content from Drupal to Joomla, and as it is not possible to throw it directly into the html view I have to cut out the php code, throw the html in, and add the php code later around again in wysiwyg.
January 21, 2009 6:43am
Hello, it would be nice if - at least optional - the editor could enter the php code in html view also. Currently I have to "transfer" pure mixed html+php content from Drupal to Joomla, and as it is not possible to throw it directly into the html view I have to cut out the php code, throw the html in, and add the php code later around again in wysiwyg.
February 12, 2009 6:30pm
I'm just learning php, but this works well for me so far and seems to have lots of awesome possibilities.
February 24, 2009 9:07pm
Hi, I'm putting php code directly into the page (not through html source) however as soon as I click save, the php portion is disappearing. this is the code im putting in. Current date is:
All that is left is the Current date is:
I've seen other people have had this problem and seen the response, which was to put the code directly in without using the html source. That is what I am doing but to no avail. What is the next step to take because it seems like the
February 24, 2009 9:19pm
"Current date is: " seems like its parsing on this comment page too so just letting u know, im putting the php code and not only the text.
February 26, 2009 2:37pm
So I followed the directions of the fix for versions 1.5.8 and on and the php code is parsing correctly. However, when I enable a wysiwyg editor in Joomla and click edit on an article, the code is gone. The code is gone but it's in the backend hidden somewhere because the php code still parses. When i turn off the wysiwyg editor I can once again see the php code. This is only a matter of convenience as I would like to not disable wysiwyg everytime I need to edit the php code. What can I do?
March 04, 2009 1:53pm
I run without an editor because joomla's default editor (Tiny MC) strips form tags. when I add the php code via source it will only read one line. If it is more than that it loses track of what is going on. The tags are left in there but it prints the contents to the page instead of the result. i.e I put in a simple echo statement -
and it couldn't printed out "echo "this is working"; after successfully printing out the date example I copied from up further on this page? So the complete code read" -
Current date and time is:
I have chronoforms plugin installed, if you were wondering about other plugins.
Any suggestions. This would really be sweet if it works for us because we use php extensively on our server-side, would be sweet to be able to work it directly into articles and etc!
Appreciate any time you take on this!
March 04, 2009 2:14pm
Well figured out that my statements being overlooked were written with the php shortcut tags instead of . Once I changed that the statements were shown, except for an include statement? I included a file that simply had a png in a link like so -- logon here
The include is being bypassed for some reason?
I have an echo statement before and after it and both fire. So thinking it is probably my statement, but they are all contained in the same tags? and the echo statements both fire so it's going through it, just not loading it. I am pretty sure that's most likely some error on my behalf so wanted to let you know I had figured out the problem I posted above.
March 06, 2009 9:25pm
This plug-in is genius! I'm moving from an html website to Joomla! and could not see how to use my mySQL database in Joomla!.
DirectPHP lets me put in the form elements I wanted, and pull the data out as I had originally programmed it. Thank you so much!
May 12, 2009 8:59pm
excellent plugin!
but i was just having trouble getting some php code to work, i dont know if the problem is with directphp or not.
i tried to display this as a content item in Joomla 1.0
heres the code:
Personal INFO
May 27, 2009 11:34am
This Worked for me with 1.5.7 and TinyMCE:
The "trick" is: you have to enter the PHP codes in the WYSIWYG mode.
Please give it a try one more time. Just copy and paste this line into the editor in the WYSIWYG mode:
June 01, 2009 9:58pm
Hi there
I am very excited to have found this. Thak you so much for taking the time and effort to help others. I am trying to have certain php pages from a site transferred to Joomla. I installed DirectPHP and have attempted to copy and paste the pages after transferring the database to the joomla database, but when I view the pages I see the scripting as text on the page. Have I missed anything? should I have done anything before trying to copy the script to the joomla pages?
August 17, 2009 6:11pm
hi i come from indonesia, i have bad english. how use
August 17, 2009 6:23pm
ahref=testimonial.php?id="?>">test
August 27, 2009 4:52am
Hi, Thanks for making a great plugin for Joomla!
I have a small problem. I am trying to create a self submitting form using PHP in an Article in Joomla!
For a self submitting form the following line has to be used:
September 13, 2009 2:35am
amazing stuff .....!! exactly what i have been looking for since a loooooong time.......!!
thanks a lot...!!
September 15, 2009 5:57pm
Hello,
I am newbie, my site is lobbyhotel.biz, i use joomla 1.5.14
This is a little suggest, maybe usefull for newbie like me..
" Don't ever copy paste script ie : Now is:
after you finished install directphp plugin but you have to write that script to your content"
Because i got trouble when i copy paste that script :) , and the answer is "write"
Thank you admin
September 25, 2009 12:47am
Hi kksou,
thanks for this great plugin.
I have here a small problem to solve:
some text .....
I get this error Parse error: syntax error, unexpected $end
Is my syntax wrong?
Hope you could give me a hint how to solve this.
Thanks
October 18, 2009 1:55am
I've had great results with this plugin!
Is it also supposed to work with the "Front End" author edit tool?
It works great while I'm in the back end admin Article editor (1.5.10), but when I visit the public site, log in as an author, and click the edit icon, Tiny MCE 2.0 doesn't encode the leading tag bracket.
Is the Joomla front end edit interface outside the influence of this plugin, or did I miss a setting somewhere? I tried "Using No Editor" and various User editor settings, but nothing seemed to work...
October 18, 2009 12:17pm
Sorry, "encode" s/b "escape" in post above. MCE, when invoked on a front end edit, does not seem to escape the leading tag bracket into & lt ; as if DirectPHP is not working there.
October 22, 2009 8:33am
Hey, Great too. Love it. I have 1 niggle... and its probably somethng you know about/fixable. I use JCE 154 editor. I edit from the front end, a lot. If i use the front end and i have previously saved code there... it's not visible... but if i access from the backed, voila... still there!!?! Strange!
maybe it's something you can have a look into?
Keep up the good work!
October 27, 2009 8:44am
i'm using no editor,
if i start with html i can intersperse with php no problem as below but