Copied to clipboard

Flag this post as spam?

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


  • Nicholas Westby 2054 posts 7103 karma points c-trib
    Nov 10, 2014 @ 23:43
    Nicholas Westby
    0

    Textbox Property Trims Leading/Trailing Whitespace?

    I have two Textbox properties, "Title Prefix" and "Title Suffix", that a user can make use of to customize page titles. Seems to work fine, except that on save Umbraco appears to be removing leading and trailing whitespace from those property values. So, a user can't really do a page title like this:

    Viewing Home on Site.com

    The prefix in that case would be "Viewing " and the suffix would be " on Site.com" (note the trailing/leading whitespace). Instead, a user gets this:

    ViewingHomeon Site.com

    Is this expected behavior? A bug? Is there anyway to force whitespace to be retained?

    Umbraco 7.1.8.

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Nov 11, 2014 @ 08:00
    Jan Skovgaard
    0

    Hi Nicholas

    Hmm, I would say it's a bug unless it's because there is no space after "Viewing" so it in the textbox says "Viewing " for instance.

    /Jan

  • Chriztian Steinmeier 2798 posts 8788 karma points MVP 8x admin c-trib
    Nov 11, 2014 @ 09:48
    Chriztian Steinmeier
    0

    Hi Nicholas,

    How are you displaying this in the template? Are you not able to tackle the problem there?

    I've done this from time to time and basically just done this:

    1. If the Prefix property isn't empty, concat the contents of that with a space (or " - ") and the @nodeName
    2. If the Suffix property isn't empty, add a space and then its contents to the previous output

    /Chriztian

  • David Sheiles 67 posts 337 karma points
    Nov 11, 2014 @ 13:15
    David Sheiles
    0

    Just to add to Chriztians solution...

    If you wanted to give them the option to have a space between the prefix or suffix, you could get them to put in a special character (e.g. ~)  at the end of the prefix or beginning of the suffix.

    Then in the template replace the character ~ with a space.

    This is a bit of a hack, so I would use Chriztian's solution unless you wanted to give the editor the option

    Dave

  • Nicholas Westby 2054 posts 7103 karma points c-trib
    Nov 11, 2014 @ 22:33
    Nicholas Westby
    0

    Thanks for the opinions and ideas for workarounds. I have reported an issue for this: http://issues.umbraco.org/issue/U4-5788

    It's surprising that nobody else seems to have encountered this (or at least not reported it). As a temporary workaround, I am doing this:

    string.Join(" ", page.TitlePrefix, page.Name, page.TitleSuffix).Trim()
    

    Not ideal, as it assumes the user wants spaces (they may or may not), but it'll do for now.

Please Sign in or register to post replies

Write your reply to:

Draft