Copied to clipboard

Flag this post as spam?

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


  • Steve 472 posts 1216 karma points
    Mar 18, 2014 @ 17:00
    Steve
    0

    item.Where()

    I am trying to test a property within a docType for a simple "true/fase" using @foreach (var item in alumniCategory.Where("notInclude != true").Take(6) ){, but it always returns as if the box is checked. What am I doing wrong.

    @using umbraco.MacroEngines
    @inherits umbraco.MacroEngines.DynamicNodeContext
    @{
        var i = 1;
    
    if (!String.IsNullOrEmpty(Parameter.slideFolder)) {
        var slideFolder = Library.NodeById(Parameter.slideFolder);
        var alumniCategory = slideFolder.Children.Where("nodeTypeAlias == \"NewsArticle\" && Visible");
    <div class="slider">
    
    @foreach (var item in alumniCategory.Where("notInclude != true").Take(6) ){
        if ( item.HasValue("featuredImage")){
    
        <div class="slide" id="@i">
    
        @if ( item.isVideo != true) {
            <a href="@item.Url"><img src="/imagegen.ashx?height=325&[email protected]("featuredImage", "umbracoFile")" /></a>
                <div class="fade">&nbsp;</div>
                <img class="logo" src="http://www.rose-hulman.edu/media/1166192/r-logo.png" />
                <div class="caption-box">
                    <div class="headline"><a href="@item.Url">@item.headline</a></div>
                        </div>
        } else {
            <a class="youtube" href="@item.videoURL?modestBranding=0&showinfo=0&autohide=1&autoplay=1&rel=0&fs=0&controls=0">
                <img src="/imagegen.ashx?height=325&image=/media/1030033/VideoOverlay.png" class="overlay" /> 
                <img src="/imagegen.ashx?height=325&[email protected]("featuredImage", "umbracoFile")" />
    
            </a>
        }
            <div class="caption">@item.copy</div>
        </div>
        i++;
        }
    }
    
    
    </div>
        }
    
    }   
        
  • Fuji Kusaka 2203 posts 4220 karma points
    Mar 18, 2014 @ 17:25
    Fuji Kusaka
    2

    Hi Steve,

    How about this?

    @foreach(var item in alumniCategory.Where("!notInclude").Take(6))
  • Steve 472 posts 1216 karma points
    Mar 18, 2014 @ 18:32
    Steve
    0

    I've tried Where("!notInclude"), Where("notInclude == false"), Where("notInclude != 0). But if I use Where("notInclude") it displays all the items with the notInclude box checked. Strange. 

    If I print the value of notInclude in the loop, it displays everything as having True except for items that I've selected the checkbox and on those I see "True True". Does that point to anything I should look at?

  • Steve 472 posts 1216 karma points
    Mar 19, 2014 @ 13:18
    Steve
    0

    Does anyone see why my code would be forcing a boolen "True" even when the property is set for "False"?

  • Jeavon Leopold 3074 posts 13632 karma points MVP 11x admin c-trib
    Mar 19, 2014 @ 18:38
    Jeavon Leopold
    0

    Try this:

    @foreach (var item in alumniCategory.Where("notInclude != @0",true).Take(6) ){
    
  • Steve 472 posts 1216 karma points
    Mar 28, 2014 @ 14:27
    Steve
    100

    Sorry, this doesn't work Jeavon. I ended up using the code below. It's confusing because it is true without checking the box "notInclue" and false if the property box is checked.

    @foreach(var item in alumniCategory.HasValue("notInclude").Take(6)){
  • Jeavon Leopold 3074 posts 13632 karma points MVP 11x admin c-trib
    Mar 28, 2014 @ 16:25
    Jeavon Leopold
    0

    Hi Steve,

    That really doesn't make any sense. You are saying a check box that isn't being checked is returning true?

    Perhaps you could try this snippet to see if it reveals anything, I would be interested to see the result?

    foreach (var node in alumniCategory)
    {
        <li>@node.Name - @node.notInclude - @node.notInclude.GetType()</li>
    }
    

    Jeavon

  • Steve 472 posts 1216 karma points
    Mar 28, 2014 @ 20:28
    Steve
    0

    Jeavon,

    It outputs the node name, nothing for the middle "@node.notInclude" and "umbraco.MacroEngines.DynamicNull"

Please Sign in or register to post replies

Write your reply to:

Draft