This is based on an earlier post (and great finding) from jtadeo
http://www.boonex.com/unity/blog/entry/How_to_Add_PHP_in_a_BLOCK
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...
--------------------
STEP 1
--------------------
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.
--------------------
STEP 2
--------------------
Edit the following file:
./inc/classes/BxDolPageViewAdmin.php
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.
--------------------
STEP 3
--------------------
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
--------------------
STEP 4
--------------------
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...
<?
// THE INSERT STARTS HERE
} elseif( $aItem['Func'] == 'PHP' ) {
?>
<tr>
<td class="form_label">PHP-code:</td>
<td> </td>
</tr>
<tr>
<td class="form_colspan" colspan="2">
<textarea style="width: 450px; height: 350px;"
name="Content"><?= htmlspecialchars_adv( $aItem['Content'] )
?></textarea>
</td>
</tr>
<?
// THE INSERT FINISHES HERE
} elseif( $aItem['Func'] == 'RSS' ) {
... etc etc...
--------------------
ET VOILA!
--------------------
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 :-)
HAVE FUN!
--------------------
DISCLAIMER
--------------------
- Don't make the modif if you're not comfortable with PHP
- This "hack" might get overridden/overwritten by future releases
Kudos newdreamers for sharing and posting this.
If you really want a challenge, do a Shindig install and run OpenSocial apps from it ;D
...sip...
works great.
can I insert a language string in to this php block?
example:
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
// START
require_once( 'inc/header.inc.php' );
require_once( BX_DIRECTORY_PATH_INC . 'design.inc.php' );
echo _t( "_MY_LANGUIAGE_KEY" );
// END
@newdreamers
works fine!
is there a fix? did boon decide to block this from happening?
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.
thanks!!!
thanx newdreamers...
Parse error: syntax error, unexpected '<' in /home/ethiomys/public_html/inc/classes/BxDolPageView.php(308) : eval()'d code on line 1
Parse error: syntax error, unexpected '<' in /home/ethiomys/public_html/inc/classes/BxDolPageView.php(308) : eval()'d code on line 1
This will work:
echo "Hello world";
This will not:
<?php echo "Hello world"; ?>
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...
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
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!
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 ??
Thanks
Daily Quotes
Parse error: syntax error, unexpected T_STRING in /home/billmark/public_html/prayerchainbook.com/inc/classes/BxDolPageView.php(561) : eval()'d code on line 3