Instead of testing the old dolphin 6.1 mod to add php blocks in dolphin 7 i decided to do something different. I am sharing it in case anyone else is interested.
I decided to use the standard HTML block as a PHP block as well.
This quick mod will allow you to use the HTML block as a PHP block.
Make the following change to inc\classes\BxDolPageView.php
At around line 537 replace the getBlockCode_Echo function.
Replace This.......
function getBlockCode_Echo( $iBlockID, $sContent ) { return '<div class="dbContentHtml">' . $sContent . '</div>'; }
With This.........
function getBlockCode_Echo( $iBlockID, $sContent ) { if(strncmp($sContent, "{PHPCODE}", 9) == 0) { $sContent = str_replace("{PHPCODE}","",$sContent); ob_start(); $aResult = eval($sContent); $sContent = ob_get_clean(); return !empty($aResult) ? $aResult : $sContent; } else { return '<div class="dbContentHtml">' . $sContent . '</div>'; } }
Now it will function as normal for html such as this.
<div>Test HTML Code</div>
But now you can use it for PHP as well. by placing a tag {PHPCODE} as the first line followed by your php code. Like so.
{PHPCODE} echo "<div>Test PHP Code</div>";
That first line with the tag {PHPCODE} tells my little mod to render it as php instead of html.
This is a very quick way of using the built in HTML block as a PHP block as well.
Hope someone finds it useful.
Merry Christmas.
https://www.deanbassett.com |
Deano,
dont know if i will find a need for it but great post and i am sure there will be plenty who find it useful. good job, and thanks for providing the information.
Merry Christmas to you and yours,
DosDawg
When a GIG is not enough --> Terabyte Dolphin Technical Support - Server Management and Support |
My site didn't like it too much
Warning: Cannot modify header information - headers already sent
by (output started at /inc/classes/BxDolPageView.php:1321) in /inc/design.inc.php on line 133 My opinions expressed on this site, in no way represent those of Boonex or Boonex employees. |
ditto - good mod. I agree with your earlier comment though- this should have been part of D7 - along with the html and rss blocks. |
My site didn't like it too much
Warning: Cannot modify header information - headers already sent
by (output started at /inc/classes/BxDolPageView.php:1321) in /inc/design.inc.php on line 133
Interesting. I will have to double check what i posted to make sure i did not miss a quote or something stupid.
https://www.deanbassett.com |
My site didn't like it too much
Warning: Cannot modify header information - headers already sent
by (output started at /inc/classes/BxDolPageView.php:1321) in /inc/design.inc.php on line 133
Interesting. I will have to double check what i posted to make sure i did not miss a quote or something stupid.
Here's line 133 in design.inc
/** * Put top code for the page **/ function PageCode($oTemplate = null) { global $echo; global $_page; global $_page_cont; global $oSysTemplate;
if(empty($oTemplate)) $oTemplate = $oSysTemplate;
header( 'Content-type: text/html; charset=utf-8' );//Line 133 $echo($oTemplate, 'page_' . $_page['name_index'] . '.html'); }
And BxDolPageView.php:1321 .... I don't quite understand. In this particular case, line 1321 is a blank line after the closing php tag. (I have a line 1321 because the entire file is double spaced.... not sure why that happens somerimes, but it never seems to hurt anything)
Anyway, I just inserted that code in BxDolPageView.php, and every page on the site hase the warnings. I do wish Boonex would officially fix it so you can use both html and php in a block.
My opinions expressed on this site, in no way represent those of Boonex or Boonex employees. |
I am not sure why it does that on your site. I double checked the posted code here, and it is fine.
Anyhow, i am working on a rewrite of the D6 mod to enable a php block to be dragged into a page from the page builder and edited like the html blocks are.
The mod for D6 will not work on D7. To many changes in the code. I will have that one done by tomarrow.
https://www.deanbassett.com |
I just posted a rewrite to the D6 php block mod. Maybe you will have better luck with that one.
http://www.boonex.com/unity/forums/topic/Add-PHP-blocks-to-Pagebuilder-for-D7.htm
https://www.deanbassett.com |
And BxDolPageView.php:1321 .... I don't quite understand. In this particular case, line 1321 is a blank line after the closing php tag. (I have a line 1321 because the entire file is double spaced.... not sure why that happens somerimes, but it never seems to hurt anything)
This is the reason you get the warning! remove any spaces or new line characters after ?> php closing tag at the end of file.
Rules → http://www.boonex.com/terms |