HTML Block Issues in 7.2

Is there a way to prevent the HTML block in the page builder from automatically changing the code after you save it?  I've tried to use these blocks for Adsense, AddThis, embedresponsively, etc, but the block continually changes the HTML code after the first save.  Sometimes it doesn't even work at all.  I've made sure to toggle the HTML editor, and am still having this issue.  Anyone else find a fix for this?

 

I've seen a handful of forum posts touch on this briefly, but nothing specific enough to help me figure it out.  Any help is appreciated, thanks!

Quote · 23 Sep 2015

Toggling the HTML editor should make it work since TinyMCE is not loaded to strip out any code upon clean-up.  You could use a php block to add your code using something like heredoc to insert long lines of code.

Geeks, making the world a better place
Quote · 23 Sep 2015

Thanks GG.  Is there an easy way to add a PHP block?  I just see RSS and HTML in the page builder.  I've also seen Deano's block tools, but it currently has 7.2 listed as not compatible.

Quote · 24 Sep 2015

 

I've also seen Deano's block tools, but it currently has 7.2 listed as not compatible.

 
A Dolphin 7.2.0 version of the tools is being worked on. Should be available in a few days.

https://www.deanbassett.com
Quote · 24 Sep 2015

Thanks Deano for updating the block tools to 7.2

 

Forgive my novice question, but what code do I need to put before and after the HTML statement to have it work properly in a PHP block?  

 

I've seen mention of echo and heredoc, but am not sure what exactly that entails and my Google search has shown me a couple different approaches that aren't specific enough for me to understand.  Embarassed

 

Anyone do this successfully on Dolphin?  I'd like to use Deano's php blocks to display third party HTML scripts, such as AddThis, EmbedResponsively, and Adsense since my HTML toggle (Non-TinyMCE) messes with the code everytime I save an HTML block.

 

Thanks in advance!

Quote · 30 Sep 2015

First of all, do not put the beginning and closing php tags as Dolphin will add those.  Adding them will only cause an error.

As for using heredoc, use a search engine such as google, yahoo, or bing and search for how to use heredoc; you will find many good examples.

Geeks, making the world a better place
Quote · 30 Sep 2015

 

As for using heredoc, use a search engine such as google, yahoo, or bing and search for how to use heredoc; you will find many good examples.

 Thanks, i mentioned I did that earlier, but saw many different approaches.  Wasn't sure if one worked better than the other.  I'll just do it on my own, thanks.

Quote · 30 Sep 2015

OK then.  The examples have the opening and closing php tags, don't include those as stated before.

Warning

It is very important to note that the line with the closing identifier must contain no other characters, except a semicolon (;). That means especially that the identifier may not be indented, and there may not be any spaces or tabs before or after the semicolon. It's also important to realize that the first character before the closing identifier must be a newline as defined by the local operating system. This is \n on UNIX systems, including Mac OS X. The closing delimiter must also be followed by a newline.

If this rule is broken and the closing identifier is not "clean", it will not be considered a closing identifier, and PHP will continue looking for one. If a proper closing identifier is not found before the end of the current file, a parse error will result at the last line.

Heredocs can not be used for initializing class properties. Since PHP 5.3, this limitation is valid only for heredocs containing variables.

Example #1 Invalid example

<?php
class foo {
    public 
$bar = <<<EOT
bar
    EOT;
}
?>


Example #2 Heredoc string quoting example

<?php
$str 
= <<<EOD
Example of string
spanning multiple lines
using heredoc syntax.
EOD;

/* More complex example, with variables. */
class foo
{
    var 
$foo;
    var 
$bar;

    function 
foo()
    {
        
$this->foo 'Foo';
        
$this->bar = array('Bar1''Bar2''Bar3');
    }
}

$foo = new foo();
$name 'MyName';

echo <<<EOT

Example #3 Heredoc in arguments example

<?php
var_dump
(array(<<<EOD
foobar!
EOD
));
?>

As of PHP 5.3.0, it's possible to initialize static variables and class properties/constants using the Heredoc syntax:

Example #4 Using Heredoc to initialize static values

<?php
// Static variables
function foo()
{
    static 
$bar = <<<LABEL
Nothing in here...
LABEL;
}

// Class properties/constants
class foo
{
    const 
BAR = <<<FOOBAR
Constant example
FOOBAR;

    public 
$baz = <<<FOOBAR
Property example
FOOBAR;
}
?>

Starting with PHP 5.3.0, the opening Heredoc identifier may optionally be enclosed in double quotes:

Example #5 Using double quotes in Heredoc

<?php
echo <<<"FOOBAR"
Hello World!
FOOBAR;
?>

Example #3 Heredoc in arguments example

<?php
var_dump
(array(<<<EOD
foobar!
EOD
));
?>

As of PHP 5.3.0, it's possible to initialize static variables and class properties/constants using the Heredoc syntax:

Example #4 Using Heredoc to initialize static values

<?php
// Static variables
function foo()
{
    static 
$bar = <<<LABEL
Nothing in here...
LABEL;
}

// Class properties/constants
class foo
{
    const 
BAR = <<<FOOBAR
Constant example
FOOBAR;

    public 
$baz = <<<FOOBAR
Property example
FOOBAR;
}
?>

Starting with PHP 5.3.0, the opening Heredoc identifier may optionally be enclosed in double quotes:

Example #5 Using double quotes in Heredoc

<?php
echo <<<"FOOBAR"
Hello World!
FOOBAR;
?>

Geeks, making the world a better place
Quote · 30 Sep 2015

Thanks GG.  I appreciate your patience and detailed help :)

 

For anyone else needing their hand held on this front, here is what I did to make it work:

 

Example Adsense Code:

<script type="text/javascript">
google_ad_client = "pub-123456789";
google_ad_slot = "123456";
google_ad_width = 180;
google_ad_height = 150;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>

 

PHP block entry excluding php opening and closing tags:

//assign adsense code to a variable
$googleadsensecode = '
<script type="text/javascript">
google_ad_client = "pub-123456789";
google_ad_slot = "123456";
google_ad_width = 180;
google_ad_height = 150;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>';
//now outputting this to HTML
echo $googleadsensecode;
Quote · 30 Sep 2015

The trouble with toggling TinyMCE off, is the damn thing keeps coming back. If you want to get rid of it entirely, look for this code in inc/classes/BxDolPageViewAdmin.php

 

        $sBlockContent = $aItem['Content'];
        //$sBlockContent = htmlspecialchars_adv( $aItem['Content'] );

        if( $aItem['Func'] == 'Echo' ) {
            $aForm['inputs']['Content'] = array(
                'type' => 'textarea',
                'html' => 2,
                'html_toggle' => true,
                'dynamic' => true,
                'attrs' => array ('id' => 'form_input_html'.$iBlockID, 'style' => 'height:250px;'),
                'name' => 'Content',
                'value' => $sBlockContent,
                'colspan' => true,
            );

Then change it to this:

        $sBlockContent = $aItem['Content'];
        //$sBlockContent = htmlspecialchars_adv( $aItem['Content'] );

        if( $aItem['Func'] == 'Echo' ) {
            $aForm['inputs']['Content'] = array(
                'type' => 'textarea',
                'html' => false,
                'html_toggle' => false,
                'dynamic' => true,
 //            'attrs' => array ('id' => 'form_input_html'.$iBlockID, 'style' => 'height:250px;'),
                'name' => 'Content',
                'value' => $sBlockContent,
                'colspan' => false,
            );
My opinions expressed on this site, in no way represent those of Boonex or Boonex employees.
Quote · 30 Sep 2015

hi i tried last step process suggested by 

but inspite of using this, my site still don't show javascript.

any idea. I have recently updated to https:

so wondering if thats a reason for this issue.

 

Quote · 4 Nov 2015

hi i am trying to add this code

iFrame Widget
```
<script type="text/javascript" src="https://s3.amazonaws.com/widgets.paper.li/javascripts/sr.iframe.min.js"></script>
<script type="text/javascript">
Paperli.PaperFrame.Show({
domain: 'newspaper.godesi.com',
pid: '501a8307-5f67-4f8c-84fa-22ed78e1075b'
});
</script>
```

Quote · 4 Nov 2015

Hi iff2in ,

I just edited  inc/classes/BxDolPageViewAdmin.php file,  based on what houstonlively suggested and

it works like charm. No more scripts disappearance and it keeps the code intact.

Many thanks houstonlively .

PS. Clear your Tools>Cache before trying the edited code. ( I am on dolphin 7.2 )

Quote · 26 Nov 2015

 

hi i tried last step process suggested by 

but inspite of using this, my site still don't show javascript.

any idea. I have recently updated to https:

so wondering if thats a reason for this issue.

 

 

What I suggested applies ONLY to adding code to html blocks in admin > Builders > Pages Builder

For this purpose, the changes DO work. 

My opinions expressed on this site, in no way represent those of Boonex or Boonex employees.
Quote · 27 Nov 2015

I am bumping this thread because it keeps coming up in other help topics.

 

Solution is to add a flag to HTML blocks so that the flag is checked before loading the block for editing.  If the use TinyMCE flag is set to "off", then don't load TinyMCE for that block when it is loaded for editing.  The default can be to use TinyMCE.  There is nothing wrong with having TinyMCE in the admin but when it is switched off for a block, then a flag needs to be set that will make sure TinyMCE is not loaded if the block needs to be edited.  That way, we have the best of both worlds when we need them.

Geeks, making the world a better place
Quote · 9 Jan 2016

I've been working on Dolphin almost daily since installing it. I implemented HL's "fix" and it does make like easier. I haven't yet used TinyMCE for the back end administration, I work with code mostly.

It just makes sense to do the below and causes people grief when it's not done.

 

I am bumping this thread because it keeps coming up in other help topics.

 

Solution is to add a flag to HTML blocks so that the flag is checked before loading the block for editing.  If the use TinyMCE flag is set to "off", then don't load TinyMCE for that block when it is loaded for editing.  The default can be to use TinyMCE.  There is nothing wrong with having TinyMCE in the admin but when it is switched off for a block, then a flag needs to be set that will make sure TinyMCE is not loaded if the block needs to be edited.  That way, we have the best of both worlds when we need them.

 

Quote · 9 Jan 2016

Hey GG,

 

Hope I'm responding to the correct place, because you said you're bumping the thread and I don't exactly know what that means.  If wrong location, just let me know and I'll post to the new location. 

 

But here's what I want to know:  What is flagging? Is that some PHP high tech term? (because I've got a good ways to go yet with the PHP)

Reason why I'm asking is because it looks like you're saying you can turn tiny MCE on and off, on for when you need it and off for when you don't.   H-Lively has come up with an incredible solution but if we could implement that plus turn on Tiny for customers, and those times when you wanna go quick and easy, that'd be great! 

 

So yes, this is a novice question: but how can I flag so I can implement the option I think you're referring to.

 

And thanks for the additional flexibility

DivineArc

Quote · 10 Jan 2016

 

It just makes sense to do the below and causes people grief when it's not done.

Bloody hell; no, it does not.  We can have both.  Sometimes it is like beating your head against a wall.

Geeks, making the world a better place
Quote · 10 Jan 2016

 

So yes, this is a novice question: but how can I flag so I can implement the option I think you're referring to.

I was talking about setting a flag in the database, an additional field that tells Dolphin when to add the TinyMCE code to the editor when a block is edited.  As HL said, we can turn off the editor but only for that instance.  Load the block to make an edit and TinyMCE loads.  We can only turn TinyMCE off after it loads.  What is needed is to set a condition, a flag, a bit, in the database for that block that says to never load TinyMCE unless I change it.

 

In pseudo code,

 

Load Block for editing;

If TinyMCE Flag = No skip loading TinyMCE;

Else, Load TinyMCE;

Geeks, making the world a better place
Quote · 10 Jan 2016

We've already made similar change it this ticket: 

https://github.com/boonex/dolphin.pro/issues/190#issuecomment-157546245

I was talking about setting a flag in the database, an additional field that tells Dolphin when to add the TinyMCE code to the editor when a block is edited.  As HL said, we can turn off the editor but only for that instance.  Load the block to make an edit and TinyMCE loads.  We can only turn TinyMCE off after it loads.  What is needed is to set a condition, a flag, a bit, in the database for that block that says to never load TinyMCE unless I change it.

 

Rules → http://www.boonex.com/terms
Quote · 11 Jan 2016

Saving the state in a cookie seems like a bad idea, what if user clears the cookie or uses a new browser? They will lose their js code as soon as they open the edit form and it will be very painful if they don't have that code backed up somewhere.

How about persisting the state on the backend? OR disabling tinymce if the content contains a <script> tag?

 

We've already made similar change it this ticket: 

https://github.com/boonex/dolphin.pro/issues/190#issuecomment-157546245

I was talking about setting a flag in the database, an additional field that tells Dolphin when to add the TinyMCE code to the editor when a block is edited.  As HL said, we can turn off the editor but only for that instance.  Load the block to make an edit and TinyMCE loads.  We can only turn TinyMCE off after it loads.  What is needed is to set a condition, a flag, a bit, in the database for that block that says to never load TinyMCE unless I change it.

 

 

so much to do....
Quote · 11 Jan 2016

 

Saving the state in a cookie seems like a bad idea,

Yes, cookies are not permanent by any means.  If you are going to go to the work of having it set a cookie, why not take it a step further and make it a real setting?

 

Let's say I have two blocks on each page of a ten page site that I need to not load TinyMCE, that is 20 cookie settings that would easily get lost if a cookie cleaning was done.

 

Geeks, making the world a better place
Quote · 11 Jan 2016

Geek-Girl,

 

Much thanks for helping us out and explaining things.  As it stands now I'm able to do things that I wouldn't have before.  I guess the whole trick on this one is understanding TinyMCE in HTML Blocks.  What it all seems to boil down to is that Tiny is very temperamental with code.  You can toggle and insert but you only get one chance and you'd better have all code customized and perfect when doing so because it won't be there if you need to edit in future.  Of course if you implement H-Lively solution it will be there, just won't have Tiny on any HTML blocks - which is fine unless you need to go quick and easy sometime.  Which is why I think you're talking about flagging. 

 

Make a long story short GG, with the great help of you and some of the others, I understand Tiny in Dolphin enough now where I should be able to work around its temperament.  It doesn't take away my user's ability to create and post [which was one of my main concerns] and I can easily get the code right the first time, and know how clear everything and fix it if for some reason I don't.

 

I really like that flagging idea though, and will probably implement once I get a little more comfortable with PHP.  In the meantime, I think I've got it all under wraps.

 

Thanks a gig

DivineArc

 

...and send anybody that needs help understanding this to me.  I think I can get them up to speed really quickly.

Quote · 12 Jan 2016

When I insert some scripts  to an HTML block , on the "Design Box Layout" the "NO Box" option won't work.

No matter what I do it will prompt back to one of the boxed options. All other Boxed options are working just fine. I was wondering if it's just me or anyone else has the same issue? 

Quote · 22 Jan 2016

I've just checked - it's working fine. Please try to switch to one of the standard templates - EVO, UNI or ALT 

When I insert some scripts  to an HTML block , on the "Design Box Layout" the "NO Box" option won't work.
No matter what I do it will prompt back to one of the boxed options. All other Boxed options are working just fine. I was wondering if it's just me or anyone else has the same issue? 

 

Rules → http://www.boonex.com/terms
Quote · 24 Jan 2016

I am using EVO .  

1) I choose "NO Box" option and then I  Save.

2) It automatically switches (or saves) my option to Box (Title, No padding) .

I tried everything even with simple HTML tags and no script it does the same thing. 

Quote · 24 Jan 2016

This problem was already fixed:

https://github.com/boonex/dolphin.pro/issues/103

Rules → http://www.boonex.com/terms
Quote · 25 Jan 2016

hi inspite of Alex update and new code in 7.3.1 , still I found old suggestion from hl better.

I replaced code to avoid code vanishing and it worked

Quote · 24 Jul 2016

Hi Alex,

In the page builder I can't see the option to select designbox option though i can change this manually from database for the particular block. 

Also, how I can assign full page to page_1.html or page_2.html or page_XXX.html or default.html. I meant about template selection either from db or from the backend. 

 

BTW, I am using 7.3.2. if you think i have to replace any core files please suggest.

Quote · 10 Oct 2016

For the "About" page you can change it in about_us.php file:

$_page['name_index']	= 0;
Rules → http://www.boonex.com/terms
Quote · 16 Oct 2016

As of version 7.3.3, when you view/edit inc/classes/BxDolPageViewAdmin.php, you will find that this line is commented out:


        $sBlockContent = $aItem['Content'];
        //$sBlockContent = htmlspecialchars_adv( $aItem['Content'] );

        if( $aItem['Func'] == 'Echo' ) {
            $sMceEditorKey = 'bx_mce_editor_disabled';
            $bMceEditor = !isset($_COOKIE[$sMceEditorKey]) || (int)$_COOKIE[$sMceEditorKey] != 1;

            $aForm['inputs']['Content'] = array(
                'type' => 'textarea',
                'html' => 2, // $bMceEditor ? 2 : 0,
                // html_toggle' => true, <--- THIS IS THE LINE!
                'dynamic' => true,
                'attrs' => array ('id' => 'form_input_html'.$iBlockID, 'style' => 'height:250px;'),
                'name' => 'Content',
                'value' => $sBlockContent,
                'colspan' => true,
            );

 

Simply "uncomment" that line (delete the forward slashes, and add the apostrophe) and save the file.

In 7.3.3, you will now find a link under the edit box to toggle to HTML editor.

Quote · 19 Nov 2016

We've removed toggle because there are two types of blocks now: Text block and HTML block.

Which is more convenient than to toggle TTML Editor.

Rules → http://www.boonex.com/terms
Quote · 19 Nov 2016
 
 
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.