I am posting this in the hopes that it will help someone. Below I describe how I use DirectPHP and the easy solutions to the three problems I encountered when migrating a bunch of PHP pages from the PHP Pages component in J1.5 to DirectPHP in J1.6.
To start, my J1.6 template is Blend-Education, which I have modified somewhat to better match our J1.5 web site at http://www.fearringtonfha.org/.
The installation of DirectPHP went without a hitch.
In converting my PHP filesI ran into three problems, each easily corrected.
First, here's how I moved my PHP pages from 1.5's PHP Pages component directory to 1.6:
- Copy code from its 1.5 directory location into a blank PHP page in NetBeans.
- Edit code in NetBeans
- Copy code from NetBeans window (CTRL-A, CTRL-C)
- Paste into article's Content window (CTRL-A, CTRL-V) in 1.6 article editor
- Test page
- Repeat steps 2-5 as necessary until the page works.
The three problems I encountered in getting the pages to work in 1.6 were
remove the ?> exit PHP and the subsequent <?php resume PHP code statements and enclose the non-PHP stuff in the PHP echo statement:
(The "<<<" is exactly three left-angle-brackets; the closure of the quote is the opening "AnyString" at the beginning of the line followed by a semicolon and nothing else.)
- Within non-quoted non-PHP text, i.e., if you want the value of a PHP variable to appear in the non-PHP code a valid construction is <?=$TheVariable?>. This is shorthand for
However, when solving the first problem above, any occurrence of the <?=...?> syntax will result in PHP code imbedded in PHP code, which causes an error. The fix is trivial: just remove the bracketing <?= and ?> leaving only the variable imbedded, and that solves the problem.
- For some reason, "mailto:-type hrefs" in <a>...<.a> links don't work when in the echo <<< format. They did not work after the Email Cloaking Module did its thing. So at the beginning of each of my PHP pages that contained a Mailto: link I inserted the following line
and that made the email links function correctly.
Otherwise everything works exactly as expected (as it did under 1.5), so converting the remaining PHP pages became just a matter of identifying and correcting the problem areas above.
I might suggest that if a PHP syntax highlighter was added to the Joomla editor as part of this plug-in, the round trips between NetBeans and the J1.6 editor would become less necessary. As it is, with all the PHP code un-indented and not highlighted or syntax-checked at all, it's difficult to find, much less debug code using the J1.6 editor.
Conclusion: Thanks for a nice solution to a difficult (for me) problem.