How to enable PHP block in the Page Builder

newdreamers posted 3rd of December 2008 in Community Voice. 31 comments.

This is based on an earlier post (and great finding) from jtadeo

This small 4-steps guide allows you to enable PHP blocks in the Page Builders interface, allowing you to, well, insert PHP inside your pages, as simple as that!

Note: I strongly recommend you backup your BxDolPageViewAdmin.php just in case...


Run the following Insert query in the pageCompose table:

INSERT INTO `PageCompose` ( `ID` , `Page` , `PageWidth` , `Desc` , `Caption` , `Column` , `Order` , `Func` , `Content` , `DesignBox` , `ColWidth` , `Visible` , `MinWidth` )
VALUES (NULL , '', '960px', 'PHP Block', '_PHP Block', '0', '0', 'Sample', 'PHP', '1', '0', 'non,memb', '0');

The key field is "Func", being set to "Sample". Any record set to "Sample" in this table will make the relevant block appear among the Samples(!) in the "page builders" section. Try and look at any page from the Page Builders screen, you'll now see the PHP block displayed as Sample.


Edit the following file:

Update the saveItem function (starting line 174) by modifying line 187:

FROM: elseif( $sFunc == 'Echo' )
TO: elseif( $sFunc == 'Echo' or $sFunc == 'PHP' )

This will enable the PHP code to be saved from the admin interface.


Modify line 553:

FROM: if( $aItem['Func'] == 'RSS' or $aItem['Func'] == 'Echo' ) {
TO: if( $aItem['Func'] == 'RSS' or $aItem['Func'] == 'Echo' or $aItem['Func'] == 'PHP' ) {

This will enable the "Delete" button in the PHP blocks popup form


Search for :

if( $aItem['Func'] == 'Echo' )

This IF condition defines what fields to display in the block popup form, based on the block type/func. You just need to insert the following on line 533
(just before the end of the IF condition for the HTML blocks):

... etc etc...

} elseif( $aItem['Func'] == 'PHP' ) {
<td class="form_label">PHP-code:</td>
<td class="form_colspan" colspan="2">
<textarea style="width: 450px; height: 350px;" name="Content"><?= htmlspecialchars_adv( $aItem['Content'] ) ?></textarea>

} elseif( $aItem['Func'] == 'RSS' ) {
... etc etc...


Now you can manage PHP blocks straight from the admin section without having to fiddle with MySQL or other geeky stuff!

Personally I can think of loads of new blocks I'm gonna create... right now actually!

Dunno what's coming up with 6.2, hope fully they'll incorporate this by default :-)



- Don't make the modif if you're not comfortable with PHP
- This "hack" might get overridden/overwritten by future releases

Please login to post a comment.
ding ding ding that is a mighy-cool-thing.

Kudos newdreamers for sharing and posting this.

If you really want a challenge, do a Shindig install and run OpenSocial apps from it ;D

Thanks for sharing...
works great.
Thank you , thank you, made my day lol!
can I insert a language string in to this php block?

I already made a new langstring in database, dont know how to insert it?
A user from UK see in this block a link with name "ocean" and the other user from Germany see "oZean".
than you
Hi miskam, here's the code your need to insert language strings below. Save it as a separate file then insert it within your php block as an "include" for example:

require_once( 'inc/' );
require_once( BX_DIRECTORY_PATH_INC . '' );
echo _t( "_MY_LANGUIAGE_KEY" );
// END
Thank you very much :-D
works fine!
@newdreamers - big ups on this! Thanks!
did all the above..usung 6.1.4 and for some reason the blocks mentioned that should be inside of PageBuilder not showing ..

is there a fix? did boon decide to block this from happening?
Hi there,

Sorry for the late reply, been away for a while. Just tried on a fresh install of Dolphin 6.1.4, applied the 4 steps above and it worked fine for me.

Let me know if I can be of any assistance.
You are the best, thank you SOOO much! Ah, and thanks for sharing, of course! Works great!
works fantastic
Hi... this technique is even beeter than previous one..
thanx newdreamers...
i am on 6.1.2 but getting :

Parse error: syntax error, unexpected '<' in /home/ethiomys/public_html/inc/classes/BxDolPageView.php(308) : eval()'d code on line 1
i am on 6.1.2 but getting error for just a simple php test code <?php echo “Hello world”; ?>

Parse error: syntax error, unexpected '<' in /home/ethiomys/public_html/inc/classes/BxDolPageView.php(308) : eval()'d code on line 1
That's because you mustn't include the PHP start/end delimiters.

This will work:

echo "Hello world";

This will not:

<?php echo "Hello world"; ?>
Thanks worked
do i still need to do this if im using 6.1.4
aaaaaaaaaaaaaaaaaaaaahhhhhhhhhhhhhhhh james t

i did it yesssssssssssssss!

i tried the first tuto but couldn't achieve step 2 from the first tuto;

so i went on with this second tuto; so now i have a block in my page builder, i need to add a php code; im still learning about this...

thank you so much; lol at first when reading this kind of tuts i thought i was about to "piewk" lol;

next is "php code";

so lets see...
one more question, if lets say what about that php block; can i have it for other pages? like profile etc?

thank you!

yeah im using 6.1.4, and it works i just have the php box enbale in my admin page builder ;

havent tried yet to add a php code!

in my case with this tuto, i tried to add a second block.

the only thing i did after accompliching the two tuto, i did step 1 with php my admin only, without redoing other steps; and i have a second block added to my admin page!
thanks for letting me know...
man i suck, i cant get pass step 1, can anyone offer any further explanation? im on the insert tab in phpmyAdmin under my DB and Table: PageCompose and then there is a long table with Field Type Function Null Value headers. , im brand new so im not sure where to insert step 1
man i suck, i cant get pass step 1, can anyone offer any further explanation? im on the insert tab in phpmyAdmin under my DB and Table: PageCompose and then there is a long table with Field Type Function Null Value headers. , im brand new so im not sure where to insert step 1

You need to run the SQL query specified in Step 1 from the "SQL" tab in phpMyAdmin, not the "Insert" one.

Be careful though, because if you're stuck at this stage then things might get quite ugly further down the process... good luck!
ThinkArchimedes tutorial (!) Great job!!! I think all of you guys are brilliant beyond comprehension for being able to think outside of the box on this kind of stuff. This is why I love programming and, in this case, dolphin! Keep up the good work friends.
Hi ,

I did all the above..using 6.1.4.
I have the new php block in page page builder but how can i add php code into the block ??

any update for Dolphin 7?
I followed the directions on my 6.1.4 install, but when I click on Pagebuilder/Homepage/PHP Block, (there are two PHP Block fields) I get "This block has no properties" coming up in red letters.
Please disregard my last question. However, I did manage to get the Quotes field showing on the home page. But with the error:

Daily Quotes

Parse error: syntax error, unexpected T_STRING in /home/billmark/public_html/ : eval()'d code on line 3
I think I must be the first to have the following problem. I have a the PHP block in my page builder, I can put it on a page and put code in it but it doesn't save it. If I put code in the block and click Save and immediately re-open the block for editing it's not there. Any idea what's wrong? Info: I'm using Dolphin 7.0.7. There's no table 'PageCompose' so I tried inserting that SQL into sys_page_compose
Solution for D7:
Below is the legacy version of the Boonex site, maintained for Dolphin.Pro 7.x support.
The new Dolphin solution is powered by UNA Community Management System.