Copied to clipboard

Flag this post as spam?

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


  • James 251 posts 1169 karma points
    Oct 13, 2014 @ 17:48
    James
    0

    Searching for a category

    Hi Guys,

    I am currently constructing a little blog. A user can create a blog post and then inside the blog post they can select from a drop down the type it is e.g. funny/ scary/ films etc.

    I have created this property and created a custom drop down type.

    Is there a way on my site that I can search for a child node with a certain property?

    Kind regards,

     

    James.

  • Nicola Nauwynck 11 posts 76 karma points
    Oct 13, 2014 @ 19:30
    Nicola Nauwynck
    100

    Hey,

    You can do this with the following:

    @{
    //moving to the page with the child items
    //if you are on the blog page with children you can get the children by using Model.content.Children()
    var home = Model.Content.AncestorsOrSelf("Home").First();
    var blogs= home.Descendants("Blog").First();
    }
    @foreach (var blog in blogs.Children().Where(x => x.GetPropertyValue("type").Equals("funny")))
    {
        // do things with blog
    }
    
  • James 251 posts 1169 karma points
    Oct 13, 2014 @ 19:50
    James
    0

    Brill thanks for the response :)

  • Nicola Nauwynck 11 posts 76 karma points
    Oct 13, 2014 @ 20:25
    Nicola Nauwynck
    0

    😀

    To make it even more dynamic you can get the page name with Model.content.Name so you can use that for the equals function

  • Ismail Mayat 4511 posts 10091 karma points MVP 2x admin c-trib
    Oct 14, 2014 @ 11:01
    Ismail Mayat
    0

    If you are using Umbraco 7 you can save yourself alot of time by using the blogging package written by Shannon http://our.umbraco.org/projects/starter-kits/articulate

  • James 251 posts 1169 karma points
    Oct 14, 2014 @ 11:05
    James
    0

    Thanks. I'm trying to learn as much as possible though. As tempting as the packages are, like you said, they save a lot of time and hence do a lot of the work for you.

     

    Thanks anyway.

Please Sign in or register to post replies

Write your reply to:

Draft