We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 15510
    • 70 Posts
    Suppose you have the following document structure:

    Doc A1
    Doc B1
    Doc C1
    Doc C2
    Doc C3
    Doc B2
    Doc C4
    Doc C5

    B-level documents contents contain a Ditto call to collect the C-level documents into a single web page. A-level and B-level documents contain a Wayfinder call to produce a list for a sidebar menu. C-level documents each contain one named anchor.

    So my desired menu structure should look like this:

    <ul>
    <li><a href="/doc_a1">Doc A1</a></li>
    <li><a href="/doc_b1">Doc B1</a></li>
    <li><a href="/doc_b1#doc_c1">Doc C1</a></li>
    ...

    Is there any way to get Wayfinder to reference the parent document so that the named references can be used? Something like [+parent_id+] would be really helpful.

    What methods have you all used to achieve this type of structure?
      • 7231
      • 4,205 Posts
      You can use the getField snippet in your innerRowTpl then use the doc id to set the anchor. Something like:
      <li><a href="[~[!GetField? &field=`id` &parent=`1`!]~]#[+wf.docid+]">[+wf.linktext+]</a></li>


      Note: you need to install the GetField snippet first.
        [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

        Something is happening here, but you don&#39;t know what it is.
        Do you, Mr. Jones? - [bob dylan]
        • 21257 MODX Staff
        • 730 Posts
        Hey wow dev_cw - thanks for the tip - I can use this!
        One thing.. after looking at the snippet, do you think kc64 might have to add the docid parameter to the snippet to make sure it’s starting with the right document?
        <li><a href="[~[!GetField? &docid=`[+wf.docid+]` &field=`id` &parent=`1`!]~]#[+wf.docid+]">[+wf.linktext+]</a></li>
        

        I could be wrong.. I’m not sure what GetField would consider the "current document" in this context.
        Thanks again
          Mike Schell
          Lead Developer, MODX Cloud
          Email: [email protected]
          GitHub: https://github.com/netProphET/
          Twitter: @mkschell
          • 7231
          • 4,205 Posts
          Good point, but in my test it worked without defining the doc. Worth looking into a bit more grin
            [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

            Something is happening here, but you don&#39;t know what it is.
            Do you, Mr. Jones? - [bob dylan]
            • 15510
            • 70 Posts
            Hey, guys.

            I just wanted to thank you for helping me with this issue. I’m disappointed to say that I haven’t made time to work this project in the last two days. I am excited to try this out.

            Does it seem that adding [+wf.parentid+] to Wayfinder might be a good idea? Seems like it would be a useful addition. Of course, it’s not the out-of-the-box solution that dev_cw suggests but it might be fun to hack a new feature into Wayfinder.
              • 15510
              • 70 Posts
              After a little hacking and some quick testing, I have found a solution which I like very much. Here’s what I did.

              My rowTpl chunk:
              <li>
                  <a href="[~[+wf.parent+]~]#prod_[+wf.docid+]">   [+wf.linktext+]</a>
                  [+wf.wrapper+]
              </li>


              What’s that [+wf.parent+] placeholder, you say? Well, I had to add the follow small changes to wayfinder.inc.php (version 2.0, 27 Feb 2006):

              line 22:
              'rowLevel' => array('[+wf.wrapper+]','[+wf.classes+]','[+wf.classnames+]','[+wf.link+]','[+wf.title+]','[+wf.linktext+]',
              '[+wf.id+]','[+wf.attributes+]','[+wf.docid+]','[+wf.introtext+]','[+wf.description+]','[+wf.subitemcount+]','[+wf.parent+]'),


              line 181:
              $phArray = array($useSub,$useClass,$classNames,$resource['link'],$resource['title'],$resource['linktext'],$useId,$resource['link_attributes'],
              $resource['id'],$resource['introtext'],$resource['description'],$numChildren,$resource['parent']);


              I haven’t done any regression testing on the mods but they seem very decoupled from the rest of the operation so I am not terribly concerned about it. Out of respect for the code writers, I had some hesitancy about the mods but I hope they will consider and advise as appropriate.
                • 25663 MODX Staff
                • 12,272 Posts
                Adding the parent indeed sounds like a useful addition. Why don’t you submit a patch using the link to the bugtracker in my signature or the forum header. smiley
                  Ryan Thrash, MODX Co-Founder
                  Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me