We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 29860
    • 59 Posts
    hi

    I am trying to build a snippet to return the active id on a nav if the document executing has the same parent doc id as the one Im passing in . It is a jagged navigation with varying items so I didnt use wayfinder

    anyways, my question is to do with how I could be doing something wrong using getParentid(). I followed http://rtfm.modx.com/display/revolution20/modX.getParentIds

    my code as follows :

      $modx = new modX();
      $parent = $modx->getParentIds(38);
      print_r($parent);  
    


    $parent just returns an empty array. I was expecting two ids to be returned, the parent doc and the container above that. The immediate parent is published

    help?
      • 28215
      • 4,149 Posts
      Why are you doing this?

      $modx = new modX();
        shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
        • 22303 MODX Staff
        • 10,725 Posts
        Quote from: thiswayup at Nov 09, 2010, 10:48 AM

          $modx = new modX();
          $parent = $modx->getParentIds(38);
          print_r($parent);  
        


        $parent just returns an empty array. I was expecting two ids to be returned, the parent doc and the container above that. The immediate parent is published

        help?
        You do not need to create the MODx object in your Snippets. It already exists. You have effectively replaced the actual working $modx object initialized by the request with an uninitialized instance that has no idea what context to load a map of Resources for.
          • 29860
          • 59 Posts
          Thanks guys. Suddenly alot of things make sense