Copied to clipboard

Flag this post as spam?

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


  • Brett Fullam 119 posts 629 karma points
    May 25, 2017 @ 14:22
    Brett Fullam
    0

    Archetype -- CSS styles not working inside RTE even though the CSS style was included in the RTE?

    Hey guys ...

    I've been looking for a solution for the last few days and finally found a reference that helped me strip out the HTML tags the RTE was rendering (paragraph and span tags) ... but I still can't get the CSS style available in the RTE to render properly?

    Here's what I used to strip the tags out ... worked perfectly:

    @Html.Raw(Model.GetValue<string>("text"))  <-- the example
    
    <div>@Html.Raw(@fieldset.GetValue<string>("hIntro"))</div>  <-- the example applied
    

    I can see and apply the style in the RTE in the back office, but it doesn't render properly. I also added the path to the css stylesheet for the custom data type in the "custom style/script options" if that helps.

    Oh ... one more detail here ... this is from an archetype on another page that's being rendered via a Partial View. Other RTE's in Archetypes that are not referenced from another page render the css styles available in the styles dropdown correctly.

    Any ideas as to why the style isn't being rendered in the referenced archetype ... ? I can provide more code-details if needed.

    Thanks in advance for any help-insight you can offer.

  • Brett Fullam 119 posts 629 karma points
    Jul 06, 2017 @ 17:42
    Brett Fullam
    101

    UPDATE ... RESOLVED

    I can't believe I overlooked this, but in order for a style sheet to be accessible (at all) in your website is to reference that style sheet in the head of your site. Otherwise you'll only see the styles in the RTE in the back office but they'll never get rendered on the front end.

    Example:

    Include the path to the css stylesheet containing the styles for your RTE:

    <link rel="stylesheet" type="text/css" href="~/css/RTE-specific.css"/>
    

    In the template (or partial view) use the following to render the RTE

    @Html.Raw(@fieldset.GetValue<string>("RTE-property-name"))
    

    This will strip out the "p" tags and only render what you included in your RTE.

    I still can't believe I overlooked this ... it's easy to assume that if your stylesheet is created and listed in the Stylesheets menu in the settings section of back office that it's accessible and will render on the front end (which is absolutely wrong).

    I hope this helps anyone else who overlooked this detail!

Please Sign in or register to post replies

Write your reply to:

Draft