Copied to clipboard

Flag this post as spam?

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


  • Sharmarke Hujale 103 posts 346 karma points
    Dec 06, 2015 @ 21:38
    Sharmarke Hujale
    0

    Truncating with GetPropertyValue

    Hi

    @ProjectPost.GetPropertyValue("content")
    

    How can I use Truncate with the GetPropertyValue - because I want to shorten the text in my article overview page.

    I've tried this without any luck:

    @Umbraco.Truncate(@ProjectPost.GetPropertyValue("content"), 150, false)
    

    /Sharmarke

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Dec 06, 2015 @ 22:40
    Dennis Aaen
    100

    Hi Sharmarke,

    If you are using strongly typed Razor you can use this code

    @Umbraco.Truncate(ProjectPost.GetPropertyValue("content").ToString(), 150, false)
    

    If you are using dynamic Razor you should use this syntax

    @Umbraco.Truncate(ProjectPost.content, 150, false)
    

    Hope this helps,

    /Dennis

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Dec 06, 2015 @ 22:47
    Dennis Aaen
    0

    Hi Sharmarke,

    You can also specify the return value after the .GetPropertyValue like this:

    @Umbraco.Truncate(ProjectPost.GetPropertyValue<String>("content"), 150, false)
    

    /Dennis

  • Sharmarke Hujale 103 posts 346 karma points
    Dec 06, 2015 @ 22:56
    Sharmarke Hujale
    0

    Hi Dennis

    I used this one:

    @Umbraco.Truncate(ProjectPost.GetPropertyValue("content").ToString(), 150, false)
    

    I have removed the "false" - to get the three dots.

    Thanks again for your help!

    /Sharmarke

Please Sign in or register to post replies

Write your reply to:

Draft