Copied to clipboard

Flag this post as spam?

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


  • Funka! 398 posts 661 karma points
    Jul 03, 2012 @ 04:21
    Funka!
    0

    Category names containing the ampersand (&) do not display or work properly

    Note, there is a bug in the umbraco core prior to 4.7.2 that won't let you edit or sort prevalues containing the ampersand, so you have to be running at least 4.7.2 if you want to attempt this. However, even so...

    The category displays as "&" so it must be getting doubly encoded. I considered editing the various razor scripts that generate the categories, perhaps to wrap them in Html.Raw, but must be missing something else because furthermore when you click on the category, the end result does not work at all. (That is, no posts are shown on that page.)

    I'm just wondering... has anyone else ran into this, or know of a possible workaround?

    Thank you!

  • Anthony Dang 1404 posts 2558 karma points MVP 3x c-trib
    Jul 03, 2012 @ 17:40
    Anthony Dang
    1

    That's an odd one.

    It turns out that the amp is not being url encoded... This causes query string category from the request to only get a string up until the amp.

    Here is a quick fix.

    do a find and replace in the list categories script. 

     

    find

    category=@c

    replace with

    [email protected](c)

     

     

     

  • Funka! 398 posts 661 karma points
    Jul 03, 2012 @ 21:17
    Funka!
    0

    Thank you! This, along with throwing an Html.Raw around the "c" for the inner link text, does seem to work.  I refactored the commonality out of each of the two cases (one for the sidebar and the other for at the bottom of each post) into a helper called drawCategoriesList which so far seems to be the only change needed to make this work. The URLs look a little funny, but I realize that's a limitation of how the categories are passed directly by name, instead of by an ID or something like their own "umbracoUlrAlias" per each category. (Not sure how one would do that using only "pre-values" in a checkbox group...)

    Thanks again!

    P.S., here's what's working for me now in uBlogsyListCategories.cshtml: Then just call this new helper via @drawCategoriesList(landing, allCategories)  and @drawCategoriesList(landing, categories) from the required places.

    @helper drawCategoriesList(dynamic landing, dynamic categories)
    {
      <ul class="uBlogsy_categories">
        @foreach (var c in categories)
        {
          if (!string.IsNullOrEmpty(c.Trim()))
          {
            <li><a href="@[email protected](c)" title="@c">@Html.Raw(c)</a></li>
          }
        }
      </ul>
    }

Please Sign in or register to post replies

Write your reply to:

Draft