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
    Feb 12, 2013 @ 20:10
    Steve
    0

    What is the proper way to check for multiple properties?

    What is the proper way to check for multiple properties?

    Model.DescendantsOrSelf().Where("Visible || nodeTypeAlias == \"ExternalLink\"");

    Is this headed in the right direction?

  • gary 385 posts 916 karma points
    Feb 12, 2013 @ 20:56
    gary
    0

    Hi

    How about

    Model.DecendantsOrSelf("ExternalLink").Where("Visible") or something to that effect in webforms.

    Did manage to stack the where statements, ie .Where("x").Where("y") and there is way to strongly type, but that is not my strength.

    Hopefully the above should get you out of this one.

    G

  • Charles Afford 1163 posts 1709 karma points
    Feb 16, 2013 @ 18:21
    Charles Afford
    0

    Hey, could you tell me what lanaguage you are using?  and what code you have at the moment?  I am guessing you are using MVC and the markup is razor?  Have you got access to any of the nodes at the moment?  On the where clause you should be just able to use a Lambda into the properties.  :)  Charles

  • Steve 472 posts 1216 karma points
    Feb 18, 2013 @ 21:09
    Steve
    0

    Charles,

    You are correct about razor, but we are using webforms. I found another way to target the node that I wanted, but I am still curious about different ways of checking for multiple properties.

    Gary,

    I didn't see your response untill after I had found another way to get to the node I wanted, so I don't know if your method would have worked. "ExternalLink" was a doctype and of course "Visible" was the umbracoNaviHide string. I had problems in the past trying to use a doctype alias as you have above- Model.DecendantsOrSelf("ExternalLink"). I made it work by using Model.DecendantsOrSelf(4).Children. Thanks again for your help!

  • gary 385 posts 916 karma points
    Feb 18, 2013 @ 21:18
    gary
    0

    Hi Steve

    Thanks for comments - much appreciated.

    Had an example today of stacking the where statements . would not work with @Model, but worked with @CurrentPage (this is Mvc, not Webforms, but think same applies, ie the dynamic). The @Model would only take one "where" statement, but at @CurrentPage took two, .Where("NodeTypeAlias == . . . . ).Where("Visible").

    I'm not technically gifted enough to explain fully, but, happy to share things that have worked, in the hope one day to be able to fully understand.

    Good luck, regards G

  • Charles Afford 1163 posts 1709 karma points
    Feb 18, 2013 @ 22:01
    Charles Afford
    0

    Hi, Steve.  You say you are using webforms?  Where abouts are you putting this markup?  Webforms would be XSLT and not a Razor markup that you suggested above?  Are you trying to do this in a masterpage/View?  Charlie :).  

    Gary, why not use a lambda?  .Where(x=>x. NodeTypeAlias && x.property ..... );

    Charlie :)

  • Steve 472 posts 1216 karma points
    Feb 18, 2013 @ 22:57
    Steve
    0

    Charles,

    Sorry, we were using webforms. Now we are using Mvc and Razor.

  • Charles Afford 1163 posts 1709 karma points
    Feb 18, 2013 @ 23:36
    Charles Afford
    0

    ah ok then what i suggest is:

    Getting some content from a get on your property.  For instance a text field on the context node. (return the properties for that node)

    Then create an extension method called 'myExampleNode' that will take that node id and node name build the <a> tag : <a href = (Nice Url) < use razor > node name < use razor </a>

    Then in your view just make a call to your extension method: Html.myExampleNode.

    Hope this makes sense.  Keeps your models and views nice and clean :)

    Charlie

     

  • Charles Afford 1163 posts 1709 karma points
    Feb 18, 2013 @ 23:38
    Charles Afford
    0

    Oh and yes in that case you can then just use a lambda so Model.property.where(x=>x.name = "" && x.name = "") ect.  You should do this in that helper method when you are returning the HTML string back to your view / partial view.

    Hope that helps. Charlie

Please Sign in or register to post replies

Write your reply to:

Draft