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 26 posts 166 karma points
    Dec 26, 2018 @ 10:25
    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 581 posts 1385 karma points
    Dec 26, 2018 @ 13:05
    Sebastian Dammark
    1

    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 26 posts 166 karma points
    Dec 27, 2018 @ 04:57
    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 113 posts 422 karma points
    Jan 01, 2019 @ 22:47
    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 1554 posts 6205 karma points MVP 5x c-trib
    Jan 04, 2019 @ 10:23
    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 26 posts 166 karma points
    Jan 08, 2019 @ 06:54
    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