+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Hierarchical Modules

Hierarchical Modules

4 posts, 0 answered
  1. Bill
    Bill avatar
    31 posts
    Registered:
    08 Apr 2013
    03 Jul 2013
    Link to this post
    I have created a Hierarchical module structure for a quiz application.
    The highest level is Lecture.  Lecture has a child module named Questions.  Questions has a child module called PossibleAnswers. 

    I created a lecture, 4 questions for the lecture and a few possible answers for each question. 

    When I retrieve the lectures there are 2 lectures returned, 1 that is status of master and visible = False, the other is status of Live and visible = True. 

    If I then get all of the questions there are 2 entries for each question 1 that is live and visibile and another that is master and not visible. 

    The issue is that the System Parent ID for all of the questions returned is the same as the id for the status = master lecture record.  Did I do something wrong when entering my data for the modules?  I would have assumed that the System Parent ID for the Live questions would be the same as the ID for the Live lecture and the System Parent ID for the master questions would match the ID for the Master lecture.

    This same pattern exists between the questions and possible answers.

    If this is normal then how do I retrieve the live questions for the Live lecture?

    I have attached a jpg image of a screen shot with sample data for review.

  2. Jonathan
    Jonathan avatar
    119 posts
    Registered:
    19 Dec 2012
    03 Jul 2013 in reply to Bill
    Link to this post
    Use something like this to access the child hierarchical items/

    DynamicModuleManager dmm = DynamicModuleManager.GetManager();
    var item = dmm.GetDataItems("DynamicModuleType").FirstOrDefault();
    dmm.LoadChildItemsHierarchy(item);
    var questions = item.SystemChildItems .Where(i =>i.Status == Telerik.Sitefinity.GenericContent.Model.ContentLifecycleStatus.Live  && i.Visible);
      
    foreach(var q in questions){
         dmm.LoadChildItemsHierarchy(q);
          var answers = q.SystemChildItems.Where(i =>i.Status ==       Telerik.Sitefinity.GenericContent.Model.ContentLifecycleStatus.Live  && i.Visible);
         foreach(var a in answers){
              var ans = a.GetValue("nameOfField");
         }
    }
  3. Bill
    Bill avatar
    31 posts
    Registered:
    08 Apr 2013
    03 Jul 2013
    Link to this post
    Thanks for the fast reply.  I will give it a try!
  4. Jonathan
    Jonathan avatar
    119 posts
    Registered:
    19 Dec 2012
    03 Jul 2013 in reply to Bill
    Link to this post
    Dont forget too that the DynamicModule builder also creates widgets for the front end too.
4 posts, 0 answered