Copied to clipboard

Flag this post as spam?

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


  • Kim Bantz Rasmussen 81 posts 310 karma points
    Aug 28, 2012 @ 13:26
    Kim Bantz Rasmussen
    0

    Tags, whitespace and filtering

    Hi all fine folks! 

    I'am making a page with filtering of cases using the jQuery plugin Quicksand. 

    I need to output a list of tags based on all the nodes with isACase == true. (First part of code)

    Futhermore the tags (datatype is a checkbox list because the tags is defined), but some are with spaces ... how can I remove the whitespace in  'This Is A Tag' so it becomes 'ThisIsATag'?

    My code:

    @{
      var root Model.AncestorOrSelf();
      var nodes root.Descendants().Where("NodeTypeAlias == @0 and Visible""Timestamp");
    }    
      
    <div class="twelve columns noPadding">
      <ul class="filter_list">
        <li class="current"><href="javascript:;" class="all-items">All</a></li>
              
                      LIST ALL TAGS HERE
      </ul>
    </div>


    <div class="twelve columns noPadding filter_items">

      @foreach (var node in nodes.Where("isACase == true").OrderBy("timelineDate desc"){
        if (@node.HasValue("casePhoto"){
          
          dynamic mediaItems @node.casePhoto.mediaItem;
                                          
          <div class="three columns case"                                     
                                          
            @if (node.HasProperty("timelineTags"){
              string[tagsList node.timelineTags.ToString().Split(',');
              if (tagsList.Count(0{
                <text>data-type="</text>
                foreach (var tag in tagsList) {
                  @tag<text> </text>
                }<text>"</text>
              }
            }  
          >
             
      
            <div class="thumb">
              <href="@node.Url" title="@node.Name">
                                              
              @if (mediaItems.Count(!= 0{
                foreach (var item in mediaItems{
                  var image item.Image;
                  <img data-original="@image.umbracoFile" src="/css/images/lazy.gif" class="lazy" alt="@image.nodeName" /
                  <noscript><img src="@image.umbracoFile" /></noscript>               
                }
              }
            
              <div><span>@node.Name</span></div>
            </a>                                       
          </div>
        </div>

        }
      }

    </div>
      

    d

  • SC Digital Services Team 104 posts 171 karma points
    Aug 28, 2012 @ 14:05
    SC Digital Services Team
    0

    Hi,

    You should be able to format your tags like so:

    @yourTagVariable.Replace(" ","")
  • Kim Bantz Rasmussen 81 posts 310 karma points
    Aug 29, 2012 @ 08:52
    Kim Bantz Rasmussen
    0

    Thanks SC Web Team - That worked! 

    Can you also help me with my other question? My problem is, that I get dublicated tags - the code runs through each node that has the 'isACase == true' and list the tags ...

    Best regards
    Kim 

  • SC Digital Services Team 104 posts 171 karma points
    Aug 29, 2012 @ 13:24
    SC Digital Services Team
    0

    From the top of my head there may be 2 ways of doing this:

    1. You can create a second array to hold the list you actually want to show on the page. Compare each tag to the new array, with a flag when a match is found. If there isn't a match (e.g. the flag isn't raised for a match), add the tag to the new array. 
    2. Use a LINQ query to find the unique value using .Distinct() - http://our.umbraco.org/forum/developers/razor/27295-Find-and-count-unique-values-in-a-dynamicNodeList-
Please Sign in or register to post replies

Write your reply to:

Draft