Developer forum

Forum » CMS - Standard features » Frontend editing news rich text field

Frontend editing news rich text field

Rune Skovbo
Reply

Hi there

 

How do you guys go about frontend editing rich text fields in the news module?

When trying to attach a CK editor to the field i get the html tags are not formattet right, giving me <p>Content</p> etc. in the text field.

Any ways of doing this out of the box - not using items?

Other solutions?

 

/Rune


Replies

 
Rune Skovbo
Reply

So it seams that CK editor posts it correctly, like this: <p>Content</p> but in the db it shows as &lt;p;&gt; etc.

We have tried many settings in the CK editor config file, but with the same result. And again - if we alert the textfield value before submitting the form, the value look correct.

 

Any ideas?

 

/Rune

 
Mikkel Ricky
Reply

Are you using the config.entities settings? Can we have a look at your CKEditor configuration file? 

How is the text stored in the database, i.e. with or without html entities?

Best regards,
Mikkel

 
Rune Skovbo
Reply

Hi Mikkel

Yes, we are using the config.entites - but with no luck.

The config file looks as follows:

/**

 * @license Copyright (c) 2003-2013, CKSource - Frederico Knabben. All rights reserved.

 * For licensing, see LICENSE.html or http://ckeditor.com/license

 */

 

CKEDITOR.editorConfig = function( config ) {

    // Define changes to default configuration here.

    // For complete reference see:

    // http://docs.ckeditor.com/#!/api/CKEDITOR.config

 

 

    // The toolbar groups arrangement, optimized for two toolbar rows.

    config.toolbarGroups = [

        { name: 'clipboard',   groups: [ 'clipboard', 'undo' ] },

        { name: 'editing',     groups: [ 'find', 'selection', 'spellchecker' ] },

        { name: 'links' },

        { name: 'insert' },

        { name: 'forms' },

        { name: 'tools' },

        { name: 'document',      groups: [ 'mode', 'document', 'doctools' ] },

        { name: 'others' },

        '/',

        { name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ] },

        { name: 'paragraph',   groups: [ 'list', 'indent', 'blocks', 'align', 'bidi' ] },

        { name: 'styles' },

        { name: 'colors' },

        { name: 'about' }

    ];

 

    // Remove some buttons provided by the standard plugins, which are

    // not needed in the Standard(s) toolbar.

    config.removeButtons = 'Underline,Subscript,Superscript';

 

    // Set the most common block elements.

    config.format_tags = 'p;h1;h2;h3;pre';

 

    // Simplify the dialog windows.

    config.removeDialogTabs = 'image:advanced;link:advanced';

    

    config.entities = false;

     config.basicEntities = false; 

    config.entities_greek = false; 

    config.entities_latin = false; 

 

 

    config.entities_additional = '';

    

    CKEDITOR.config.allowedContent=true;

 

    config.htmlEncodeOutput = false;

 

 

 

};

In the DB the text looks like this:

&lt;h1&gt;aerghhaa&lt;/h1&gt;<br><br>&lt;p&gt;aerhgiou&lt;/p&gt;<br>

 

Is that helpful?

 

/Rune

 
Rune Skovbo
Reply

Further testing...

Using a regular news V2 frontend editing template without CKeditor, the newsText field is just a plain textarea. If we type <p>content</p> into that field, we get the same result in the DB - &lt;p&gt;content etc. so the issues does'nt seem to be with the CK Editor. But rather with the way DW stores the data in the DB?

 

Security reasons?

 

/Rune

 
Rune Skovbo
Reply

Anyone?

 
Mikkel Ricky
Reply

What exactly do you mean by "When trying to attach a CK editor to the field"?

As your investigation suggests, the News module html encodes values in long text fields before storing them in the database.

Best regards,
Mikkel

 
Rune Skovbo
Reply

Well, the News module outputs the newsText as a simple textarea field. We want to add the same editing options to that field frontend, as you have backend.

So in the News frontend editing template we use the CK editor to "transform" the textarea (newsText) field to a ricktext editor field.

 

/Rune

 
Mikkel Ricky
Reply

Try decoding the actual value before calling CKEDITOR.replace, i.e. use

@System.Web.HttpUtility.HtmlDecode(item.GetString("News:Text"))

in a Razor template, or use 

<!--@News:Text.HtmlDecoded()-->

in a HTML template.

Best regards,
Mikkel

 
Rune Skovbo
Reply

Hmm well the problem is, that it is the textarea field itself i need to manipulate. This is a place to create news, so there is no "actual value" to HTML decode, before we create it in the textarea field. 

In other words, the tag I am using is this:

<!--@NewsText_ctrl--> 

This tag gives me: <textarea name="NewsText" id="NewsText" rows="5" cols="30" class="FrontendStd" ></textarea>

Here I add the ckeditor class and it ends up looking like: <textarea name="NewsText" id="NewsText" rows="5" cols="30" class="FrontendStd ckeditor" ></textarea>

... Or am I misunderstading what you are suggesting?

 

/Rune

 
Mikkel Ricky
Reply

If you have an empty textarea then I don't understand when the problem with encoded values in the editor shows up. It should only be a problem when editing news items, right?

 
Rune Skovbo
Reply

No, everything looks right in the textfield manipulated by CK editor in the frontend. The problem is, that when i view my newly frontend created news in the backend (news module).

 

So - I create news frontend via the CK editor without problems. I then look at the same news backend and see that the formatting is wrong.

 

/Rune

 
Rune Skovbo
Reply

Did you get a chance to look into this issue?

/Rune

 
Mikkel Ricky
Reply
This post has been marked as an answer

"Frontend editing" using the news module does not handle formatted text (as we've learned) and we don't plan on changing/fixing this. You should really consider using items for your news.

Best regards,
Mikkel

Votes for this answer: 1
 
Rune Skovbo
Reply

Ok.

 

You do offer a rich text editor option as a costum field though. Unfortunately that doens'nt work at the moment - it's raported as a bug, last i heard.

 

Thanks for your help.

 

/Rune

 

You must be logged in to post in the forum