Forum

Thread tagged as: Problem, CKEditor

Text Item Removes Div Formatting

Hello, I am having issues with adding content to one of the items in a region. I add the following code:

<div style="display:none;background:#D74D4F;border:dashed 4px #FF0004;box-sizing:border-box;text-align:center;align-content:center;">
    <p>Clicking "Subscribe" more than once could result in being charged more than once.</p>
</div>

But upon saving I find that the code was reduced to:

<p>Clicking &quot;Subscribe&quot; more than once could result in being charged more than once.</p>

Which removed all of the formatting. Just above this section is a div that has formatting that seems to work:

<div style="background:#eee; border:1px solid #ccc; padding:5px 10px"><strong>After signing up for one of these services, you will receive several emails with detailed instructions on&nbsp;setting up your device. You should receive these emails with 48 hours.</strong></div>

Mimicking this div and having the exact same styling causes the div I'm trying to add to work properly, but reducing the styling on the div to even just a background attribute still results in the simple paragraph tag.

If you need the diagnostics report, here it is:

Perch: 2.8.13, PHP: 5.4.43, MySQL: mysqlnd 5.0.10 - 20111026 - $Id: c85105d7c6f7d70d609bb4c000257868a40840ab $, with PDO
Server OS: Linux, cgi-fcgi
Installed apps: content (2.8.13), assets (2.8.13), categories (2.8.13), perch_forms (1.8.2), perch_shop_foxycart (2), perch_shop_foxycart (2.1), perch_members (1.3), perch_backup (1.2)
App runtimes: <?php $apps_list = array( 'content', 'categories', 'perch_forms', 'perch_shop_foxycart', 'perch_members' );
PERCH_LOGINPATH: /perch
PERCH_PATH: /home/cloudveil/public_html/perch
PERCH_CORE: /home/cloudveil/public_html/perch/core
PERCH_RESFILEPATH: /home/cloudveil/public_html/perch/resources
Image manipulation: GD Imagick
PHP limits: Max upload 32M, Max POST 48M, Memory: 64M, Total max file upload: 32M
Resource folder writeable: Yes
SCRIPT_NAME: /perch/core/settings/diagnostics/index.php
REQUEST_URI: /perch/core/settings/diagnostics/
DOCUMENT_ROOT: /home/cloudveil/public_html
HTTP_HOST: cloudveil.org

I'm really confused. Is anyone out there able to enlighten me?

Caden Peters

Caden Peters 0 points

  • 6 years ago

I think you would really need to post your template code to work out why it's stripping html. Does the template for the field you're posting in have html="true" for example? If not, it may strip the markup.

I would be tempted, where possible, to put the HTML in the template, so you only have to enter the text in the CMS. That may not be possible in your setup, but that's what I'd aim for.

Drew McLellan

Drew McLellan 2638 points
Perch Support

You've categorised this post as CKEditor - is that where you're entering your HTML? If so, you need to check with the CKEditor project about how it handles HTML, as it's not something Perch is doing.

I don't seem to have striptags enabled (nor disabled, but I hope that's the default), and I do have html="true" enabled in that place, but if it were stripping based on a setting then that other div wouldn't/shouldn't be able to exist the way it does, anyway.

Here is the template code:

<perch:blocks>
    <perch:before>
        <div class="full_width clearfix">
            <div class="wrapper">
    </perch:before>
        <perch:block type="text1" label="Text and Code">
                <div class="grid_4 hide">
                            </div>
                    <div class="grid_8">
                        <perch:content id="text" label="Text" type="textarea"  editor="ckeditor" html="true" />
                    </div>

                    <div class="grid_1">
                        <perch:content id="texts" type="textarea" label="Code" html="true" editor="ace" />
                    </div>
    </perch:block>
    <perch:block type="text2" label="Text and Image">
                    <div class="grid_4 hide">
                        </div>

                    <div class="grid_8">
                        <perch:content id="text123" label="Text" type="textarea"  editor="ckeditor" html="true" />
                    </div>

                    <div class="grid_1">
                            <a href="<perch:content type="text" id="imagelink" label="Image Link"/>" ><img src="<perch:content type="image" id="image" label="Image" />" alt="<perch:content type="text" id="alt" label="Description" required="false" help="e.g. Photo of MD John Smith with his best wig on" title="true" />" /></a>
                    </div>
    </perch:block>
    <perch:after>   
            </div>
            </div>
    </perch:after>
</perch:blocks>

In this situation I don't really think I want to put it into the template, though I suppose I could create a new template based off this one to allow for my specific circumstance.

Drew McLellan said:

You've categorised this post as CKEditor - is that where you're entering your HTML? If so, you need to check with the CKEditor project about how it handles HTML, as it's not something Perch is doing.

I see. I will check there, then! Thank you.

That made it work fine. Thanks for the help!