Copied to clipboard

Flag this post as spam?

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


  • Fuji Kusaka 2203 posts 4220 karma points
    Dec 11, 2012 @ 13:42
    Fuji Kusaka
    0

    Splitting Multiple TextString

    Hi,

    Am actually using the Multiple TextString in V4.9.1 and having some difficulty to display each TextString. The Multiple TextString is being used in the media section attached to a MediaType to enable user to add Slogan to there banner slideshow.

    Here is my code 

     

    if(slide.HasValue("slideshowHeading") && slide.Where("slogan")){
    @:{image : "@slide.umbracoFile", title :"<h1>@foreach(var t in slide.slideshowHeading){@t <br/>} </h1>"},
                          
    }

    Here is the output from 2 textString 

    {image : "/media/4187/01-dimg.jpg", title :"<h1>d<br/>&#39;<br/>t<br/>e<br/>s<br/>t<br/> </h1>"},

     

    The desired output would be 

    {image : "/media/4187/01-dimg.jpg", title :"<h1>d&#39;<br/>test<br/> </h1>"},

    Any idea what am doing wrong here ?

     

  • Lee Kelleher 4024 posts 15833 karma points MVP 13x admin c-trib
    Dec 11, 2012 @ 14:28
    Lee Kelleher
    0

    Hi Fuji, what is outputted when you just do:

    @slide.slideshowHeading

    ?

    I'm curious if it's "DynamicXml" or something else?

    Thanks, Lee.

  • Fuji Kusaka 2203 posts 4220 karma points
    Dec 11, 2012 @ 14:33
    Fuji Kusaka
    0

    Hi Lee,

    Well i get this

    {image :"/media/4187/01-dimg.jpg", title :"<h1>d&#39; test<br/> </h1>"},

    Btw the way am in the media section here, where i need a <br/> tag between each added Textstring for the headers

  • Lee Kelleher 4024 posts 15833 karma points MVP 13x admin c-trib
    Dec 11, 2012 @ 15:11
    Lee Kelleher
    0

    Hmmm... which Multiple Textstring are you using? the native one (that comes with Umbraco default) or the uComponents version?

    Only I'd expect the value to be a DynamicXml ... otherwise for the uComponents version it should have a model binder that uses a "List<string>".

  • Fuji Kusaka 2203 posts 4220 karma points
    Dec 11, 2012 @ 15:15
    Fuji Kusaka
    0

    Using the one from Umbraco Default in v4.9.1.

  • Fuji Kusaka 2203 posts 4220 karma points
    Dec 11, 2012 @ 16:03
    Fuji Kusaka
    0

    Any Idea what i should do ?

  • Lee Kelleher 4024 posts 15833 karma points MVP 13x admin c-trib
    Dec 11, 2012 @ 16:06
    Lee Kelleher
    0

    Honestly, I'd be expecting an DynamicXml object to come back from the default Multiple Textstring.  Since it's not doing that, (for whatever reason), I'd suggest trying to split the string into an array.

    @foreach(var t in slide.slideshowHeading.Split(' ')){@t <br/>}

    If the " " (space) doesn't work, then try a "\n" (newline) ... sorry, it's all guesswork by me (I still do it all in XSLT).

    Cheers, Lee.

  • Fuji Kusaka 2203 posts 4220 karma points
    Dec 11, 2012 @ 16:50
    Fuji Kusaka
    100

    This did the trick 

    @:{image : "@slide.umbracoFile", title :"<h1>@foreach(var t in slide.slideshowHeading.Split('*')){ @t @Html.Raw("<br/>")}</h1>"},

    So everytime the user enters the * symbol in the textString it assumes it will go on the next line.

    Thanks for your time Lee

    //fuji

  • Lee Kelleher 4024 posts 15833 karma points MVP 13x admin c-trib
    Dec 11, 2012 @ 16:52
    Lee Kelleher
    0

    No worries Fuji, glad that you found a solution.  (Still curious what the underlying issue is/was.)

    Cheers, Lee.

Please Sign in or register to post replies

Write your reply to:

Draft