Copied to clipboard

Flag this post as spam?

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


  • Ben Norman 167 posts 276 karma points
    Nov 06, 2011 @ 23:54
    Ben Norman
    0

    Best Practice: Folder Finder

    using 4.7.1

    @foreach (var group in Model.AncestorOrSelf().Children.Where("Name == \"News\"").First().Children)
    
    Is it normal to find a folder in the above way or is there a better way to do it?
  • Anthony pj 40 posts 63 karma points
    Nov 07, 2011 @ 01:04
  • Bert 128 posts 251 karma points
    Nov 07, 2011 @ 01:50
    Bert
    0

    It all depends what you want and need. If the foldername, folder location in the tree ... might change or a user might create one that would conflict your selection logic, maybe use the following approach.

    Make the top node a 'setting node'. Put a contentpicker there that will remember this important folder. In your script first get the settingsnode and then get the required property.

        //Get the settings of the website
       
    var siteRoot = Model.AncestorOrSelf();
       
    //Select the contentpicker
       
    var folder = siteRoot.FolderContentPickerProperty;

     

  • Ben Norman 167 posts 276 karma points
    Nov 07, 2011 @ 01:52
    Ben Norman
    0

    Yeah, nice one!

Please Sign in or register to post replies

Write your reply to:

Draft