We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22629
    • 194 Posts
    I have a Wayfinder menu-builder built into my template - firstly UltimateParent runs to find the document’s top-level parent, then Wayfinder runs on that parent to create a menu of the current site section.

    If the template is ran on a published document, UltimateParent returns the correct ultimate parent’s menu, however if the template is on an unpublished document, UltimateParent returns the current document’s ID, not it’s parent - so Wayfinder doesn’t run correctly.

    Any ideas how I can set UltimateParent to work correctly on an unpublished document as I couldn’t find much in the snippet’s comments.
      Andy Shellam | www.networkmail.eu | @Pandy06269 @NetworkMail

      modx Revolution 2.2.6
      Windows 2012 | IIS 8 | php 5.4.11 | MySQL 5.5.29

      Content-Managed Websites Built on MODX
      • 22629
      • 194 Posts
      OK, think I’ve got this sorted too, in UltimateParent, I’ve altered the following lines:

      $pid = $modx->getParent($id,1,’id’);

      (repeated in the while loop as well)

      to:

      $pid = $modx->getParent($id,0,’id’);

      The documentation however for $modx->getParent says:

      $parent = $modx->getParent(55,1,’pagetitle’);

      will return the title of the parent of document 55 if the parent is published.
      $parent = $modx->getParent(55,0,’id’);

      will return the parent document’s id if it is not published.

      However the parent document is published, it’s the current document that isn’t.
        Andy Shellam | www.networkmail.eu | @Pandy06269 @NetworkMail

        modx Revolution 2.2.6
        Windows 2012 | IIS 8 | php 5.4.11 | MySQL 5.5.29

        Content-Managed Websites Built on MODX
        • 17895
        • 209 Posts
        You should do a search in the forums before asking anything :-P

        Some hours BEFORE your request, I posted the solution to your problem!!

        http://modxcms.com/forums/index.php/topic,10434.0.html
          Daniele "MadMage" Calisi
          • 22629
          • 194 Posts
          Yes I had seen your post, but mine is not alluding to the parents being unpublished - it’s when the current document the snippet is being run on is unpublished.

          The Modx documentation is either inaccurate, or there is a bug in the $modx->getParent call.

          When the current document is unpublished, $modx->getParent returns the current document ID, not it’s parent ID (regardless of whether the parent is published or not.)

          If this is the correct/desired behaviour, then the documentation is incorrect.
            Andy Shellam | www.networkmail.eu | @Pandy06269 @NetworkMail

            modx Revolution 2.2.6
            Windows 2012 | IIS 8 | php 5.4.11 | MySQL 5.5.29

            Content-Managed Websites Built on MODX
            • 17895
            • 209 Posts
            Quote from: andyccn at Dec 29, 2006, 07:51 AM

            Yes I had seen your post, but mine is not alluding to the parents being unpublished - it’s when the current document the snippet is being run on is unpublished.
            ...anyway, my UltimateParentPlus solve also your problem

            The Modx documentation is either inaccurate, or there is a bug in the $modx->getParent call.

            When the current document is unpublished, $modx->getParent returns the current document ID, not it’s parent ID (regardless of whether the parent is published or not.)

            If this is the correct/desired behaviour, then the documentation is incorrect.

            Yes, it seems there is something not written clearly in the documentation... anyway, why do you want to run a snippet on a unpublished page?
              Daniele "MadMage" Calisi
              • 22629
              • 194 Posts
              Quote from: madmage at Dec 30, 2006, 12:05 PM
              Yes, it seems there is something not written clearly in the documentation... anyway, why do you want to run a snippet on a unpublished page?

              I don’t particularly, I discovered this problem while working on a new group of documents for a section for my site, and it took me a while to find out why the navigation bar wasn’t picking up the correct parent section, even though the section itself was published.
                Andy Shellam | www.networkmail.eu | @Pandy06269 @NetworkMail

                modx Revolution 2.2.6
                Windows 2012 | IIS 8 | php 5.4.11 | MySQL 5.5.29

                Content-Managed Websites Built on MODX