XF 2.0 How to use xf:editorrow ?

keithg

Member
I am having some issues with re-editing content in the Rich text Editor. The previously saved HTML content is not being processed by the editor and the raw html is being displayed:

<p>content</p>

Background info:
I created a new "paid forum" entity with several fields that hold meta data for a very few selected forums. I extended the forum_edit template to add the extra new entity fields to keep a simple UI. The new entity is created / modified / deleted along with the forum it is associated with. One of the extra entity fields was a "description" field which I originally used a xf:textarearow to display and capture the data. I have working code to save the new entity and do additional processing as required: including a view of the new entity and a payment system.

All was working just fine. But the admin users quickly identified that they wanted to use a Rich Text Editor to author the description field content instead of having to enter HTML tags. Makes sense.

I discovered the xf:editorrow and initially changed the xf:textarearow to xf:editorrow in the extended forum_edit template . This caused the RTE to be displayed on the forum edit but caused some other side effects.
a) The actual form data is now stored in a field called "description_html" as opposed to "description" (i have solved this issue)
b) The captured data is being stored as html in the database - so it displays properly in a view of the new entity. But the html is not being pre-processed by the RTE when someone re-edits the forum. This causes the data to get corrupted when it is re-saved.

I have been unable to find any other posts here or good examples in the code base that would give me guidance on best practices.

Questions:
1) how to get the raw HTML to be processed properly by the RTE?
2) should I be doing something else other than using raw HTML? It appears that normal thread posts not stored as HTML, but some other type of code (BB code? whatever that is...)

I ask the second question since one of the users wants to embed a video link such as
To view this content we will need your consent to set third party cookies.
For more detailed information, see our cookies page.
in the description field and this does not render properly when I display the entity via {$pforum.description|raw} . This leads me to think I need to learn more about BB code and maybe store / render the description data differently?
 
The template syntax i used for the RTE is
<xf:editorrow name="pforum[description]" value="{$pforum.description}" autosize="true"
mode="html"
label="{{ phrase('description') }}"
hint="{{ phrase('you_may_use_html') }}"
explain="{{ phrase('node_description_explain') }}" />
 
The answer is to store rich text data as BBcode and not HTML. BBcode data from the database is magically displayed properly by the Rich Text Editor.

It took some effort to discover that this required a few simple changes to my world
- convertToBbCode the HTML data prior to save
- bb_code the saved data in my template at display time
 
Back
Top Bottom