Copied to clipboard

Flag this post as spam?

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


  • Moran 277 posts 885 karma points
    Apr 03, 2013 @ 10:39
    Moran
    0

    Getting properties from document type

    I want to get all the properties from a document type VIA razor script, to be exact, I want to get all the properties from a specific tab in the document type.

    is there any way that I can do it?

  • Jan Skovgaard 11258 posts 23500 karma points MVP 7x admin c-trib
    Apr 03, 2013 @ 22:37
    Jan Skovgaard
    0

    Hi Moran

    If you just need to get the values from the page you're currently on you should be able to simply write @Model.YourPropertyName for each of the properties you need to fetch the values from.

    You can read more about the Razor syntax here http://our.umbraco.org/documentation/reference/Templating/Macros/Razor/

    /Jan

  • Moran 277 posts 885 karma points
    Apr 04, 2013 @ 06:31
    Moran
    0

    Yes, I am fimiliar with that.

    but is there a way to get to a specific tab in my properties and iterate througth them with a loop of some sort? instead of getting to each one?

  • Fuji Kusaka 2203 posts 4220 karma points
    Apr 04, 2013 @ 08:13
    Fuji Kusaka
    100

    Hi Moran,

    What you could do is run a test to match all nodes using the same docType first.

    if(@Model.Where("NodeTypeAlias == \"DocType\"")){
     //your Property Name
    }

    or

    @foreach(var item in Model.Children.Where("NodeTypeAlias == \"DocType\"")){
    // @item.propertyName
    }
  • Moran 277 posts 885 karma points
    Apr 04, 2013 @ 08:50
    Moran
    0

    Ok

    so this will get me all the nodes by doc type, and how cann I get all the properties from that node? without writing them down all of them.

  • Fuji Kusaka 2203 posts 4220 karma points
    Apr 04, 2013 @ 09:56
    Fuji Kusaka
    0

    Hi Moran,

    In any case you will need to make use of the propertyAlias to call the infos. In the example above

    @item.propertyAlias 
  • Moran 277 posts 885 karma points
    Apr 04, 2013 @ 10:37
    Moran
    0

    Thanks

    I think I need to change the way I think about it, giving the users too many fields to fill for every page isn't a good practice.

  • Rich Green 2246 posts 4006 karma points
    Apr 04, 2013 @ 10:49
    Rich Green
    0

    Hey Moran,

    I understand what you're trying to do, however I can't work out why you would need to do it, maybe like you say there is another way to think about it?

    Let us know.

    Rich

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies