Copied to clipboard

Flag this post as spam?

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


  • James 251 posts 1169 karma points
    Jul 21, 2014 @ 22:09
    James
    0

    Umbraco.Truncate

    Hi I have the following code:

    @Umbraco.Truncate(@page.PortfolioItemBodyText, 50)

    When i load my view that is meant to display this text it shows nothing.

    If i put just:

    @page.PortfolioItemBodyText

    It displays the text that is available.

    Why would this not work?

    The code worked before, until i deleted the portfolio items and recreated them I have had issues.

    But i can write the text to the page using @page.PortfolioItemBodyText no problem.

    Kind regards.

     

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Jul 21, 2014 @ 22:19
    Dennis Aaen
    0

    Hi James,

    What if you do it like this:

    @Umbraco.Truncate(page.PortfolioItemBodyText, 50)

    Hope this helps,

    /Dennis

  • James 251 posts 1169 karma points
    Jul 21, 2014 @ 22:26
    James
    0

    Still nothing :(

    Heres the full code:

    @foreach(var page in CurrentPage.DescendantsOrSelf(3).OrderBy("CreateDate desc").Take(4))

     {

                <div class="col-md-3 col-sm-6">

                    <div class="thumbnails thumbnail-style thumbnail-kenburn">

                        <div class="thumbnail-img">

                            <div class="overflow-hidden">

                                <img class="img-responsive" src="@page.PortfolioItemCoverPhoto" alt="" />

                            </div>

                            <a class="btn-more hover-effect" href="@page.Url">read more +</a>

                        </div>

                        <div class="caption">

                            <h3><a class="hover-effect" href="@page.Url">@page.PortfolioItemTitle</a></h3>

                            @Umbraco.Truncate(@page.PortfolioItemBodyText, 10)

                        </div>

                    </div>

                </div>

    }

    Was working perfectly until i deleted all the portfolio items and added 2 new ones.

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Jul 21, 2014 @ 22:41
    Dennis Aaen
    0

    Hi James,

    Maybe a silly question, but you say that you donĀ“t get any data out after you have deleted and re-created the items, again, did you make sure that the field has some text on the page that you are visit? To me it could sounds that the field could be empty on that page.

    /Dennis

  • James 251 posts 1169 karma points
    Jul 21, 2014 @ 22:45
    James
    0

    I can get data fine when i request it by doing:

    @page.PortfolioItemBodyText

    But if i try to truncate it it doesnt display anything

    there is more than 100 characters of text

    Regards.

     

  • Nicholas Westby 2054 posts 7103 karma points c-trib
    Jul 21, 2014 @ 23:55
    Nicholas Westby
    100

    I just ran into a similar issue today when working with some imported rich text. The problem for me was that the beginning of the string had lots of HTML comments and whitespace. I used HtmlAgilityPack to remove the comments and a regular expression to replace the repeated whitespace.

    Try outputting the length of the string rather than the actual string to see if it does have a length of 50.

Please Sign in or register to post replies

Write your reply to:

Draft