Copied to clipboard

Flag this post as spam?

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


  • Bo Damgaard Mortensen 712 posts 1189 karma points
    Jul 13, 2018 @ 10:30
    Bo Damgaard Mortensen
    0

    Remove HTML from Nested Content header

    Hi all,

    Does anyone know if it's possible to strip HTML from the Nested Content header?

    My header is set to render the first 100 characters of a RTE (since that's the only property on the document type), but it outputs the paragraph tags:

    enter image description here

    Thanks in advance :-)

  • Søren Kottal 530 posts 3521 karma points MVP 2x c-trib
    Jul 13, 2018 @ 15:36
    Søren Kottal
    1

    Try setting the label to something

    {{ bodyText.replace(/(<([^>]+)>)/ig, "").substring(0,100) }}

    assuming your property alias is bodyText.

  • Bo Damgaard Mortensen 712 posts 1189 karma points
    Jul 14, 2018 @ 08:51
    Bo Damgaard Mortensen
    0

    Thanks a lot for your reply, Søren!

    That was my thoughts exactly, but it gives me this in the console:

    enter image description here

    Not sure if it's possible to perform JS magic inside the angularjs brackets (?) Also tried with just {{ bodyText.innerText }} and {{ bodyText.text() }}, but no result :-)

  • Marcel van Helmont 68 posts 259 karma points c-trib
    Jul 14, 2018 @ 17:07
  • BY-DGR 1 post 93 karma points
    Jul 19, 2019 @ 09:34
    BY-DGR
    102

    If the question is still relevant, here is the solution we're using in our projects:

    {{!!BodyText ? (BodyText | ncRichText | limitTo:100).trim() + '…' : '<Empty Content>'}}
    

    It appeared that this Angular filter is listed in "Nested Content" manual: https://our.umbraco.com/documentation/getting-started/backoffice/Property-Editors/Built-in-Property-Editors/Nested-Content/

  • Andrei 8 posts 78 karma points
    May 07, 2020 @ 13:43
    Andrei
    1

    Found out there is a 'truncate' filter also available (8.6+), so I'm using it like this:

    <ComponentName>{{!!heading ? ': ' + (heading | ncRichText | truncate:true:150) : ''}}
    

    'true' param says keep whole words - I think

    150 - max length

    dots (...) are added if the text is longer

    This is a little better then previous answer, because here, the ending dots are only added when the text is too long.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies