Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Tuan Nguyen 25 posts 165 karma points
    22 days ago
    Tuan Nguyen
    0

    RTE wrap multi <p> tags into <div> single tag

    Hi Masters,

    I want wrap 2 <p> tags into <div> single tag.

    Inputted:

    <p>This is an Description1.</p>
    <p>This is an Description2.</p> 
    

    Expected:

    <div>
        <p>This is an Description1.</p>
        <p>This is an Description2.</p> 
    </div>
    

    Action: I have customized StyleSheet as below image enter image description here On Rich Text Editor, I used with this custom style

    Result:

    <div>This is an Description1.</div>
    <div>This is an Description2.</div>
    

    Please help me.

    Thanks

    Tuan Nguyen.

  • Sebastian Dammark 492 posts 1122 karma points
    21 days ago
    Sebastian Dammark
    0

    Just wrap the property output in a like this.

    <div>Model.GetPropertyValue(“propertyAlias”)</div>
    

    Remember to check first if the property has any value with HasProperty

    Model.Content.HasValue(“propertyAlias”)
    
  • Tuan Nguyen 25 posts 165 karma points
    21 days ago
    Tuan Nguyen
    0

    Thanks for the solution, Sebastian.

    But I want when Editor typed words and format as image

    enter image description here

    When Editor click "View Source Code", the result should display correctly.

    Actual Result

    enter image description here

    Expected Result

    enter image description here

    Thanks.

  • MB 33 posts 184 karma points
    15 days ago
    MB
    0

    Umbraco uses tinyMCE for its RTE.

    It parses the content and applies rules, and I believe this is the default action of that product.

    Perhaps check out /config/tinyMceConfig.config to see if there is a setting you can tweak to get what you need - specifically the valid elements rules.

    It's also a pain at times, by marking entire paragraphs with a single custom format, instead of just the selected text, but tinyMCE support have shown no interest in allowing more control over that feature.

  • Dan Diplo 1419 posts 5365 karma points MVP 2x c-trib
    1 week ago
    Dan Diplo
    0

    If you are a confident C# developer then you can hook into Umbraco events to manipulate the content when it is saved using the HTML Agility Pack (that comes as part of Umbraco install).

    So you'll need to raise the Content Service saving event in an ApplicationEventHandler and then use the HTML Agility Pack to parse and reformat the HTML which would then save it back to Umbraco. Tricky, but possible.

  • Tuan Nguyen 25 posts 165 karma points
    1 week ago
    Tuan Nguyen
    0

    Thanks Dan,

    I will try your solution in next time, I think this solution is the right way to render source code property on RTE.

    Thanks.

    Tuan Nguyen.

Please Sign in or register to post replies

Write your reply to:

Draft