We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 29125
    • 12 Posts
    I want a wayfinder generated menu to have a dynamic table of contents structure as follows:

    1.Parent Title (parent menuindex = 1)
    1.1 Child Page (child menuindex = 1)
    1.2 Child Page (child menuindex = 2)
    2. Chapter Parent (parent menuindex = 2)
    2.1 Child Page (child menuindex = 1)
    2.2 Child Page (child menuindex = 2)

    where if I insert or move any item the numbers regenerate based on the menuindex assigned to each resource. My menu will only show one parent and its children (for now) in the left column of a page. I can generate the page menuindex using [*menuindex*] or via a php snippet, but I can’t figure out how to get the parent menuindex for a child page and print it in wayfinder output. Thanks for any suggestions.
      • 29525
      • 388 Posts
      I’m also interested in this.
        www.terrybarthdesign.com
        • 29125
        • 12 Posts
        I created a template variable [*toc*] and I’m trying to bind the menuindex for each row in Wayfinder to the TV.

        The Input Type is "text" and the Default Value:

        @SELECT menuindex FROM modx_site_content WHERE id=10

        This returns a menu that looks like this:

        Array pagetitle

        So I need to figure out how to make Wayfinder process the TV for each row and print the menuindex instead of "Array".
          • 29125
          • 12 Posts
          I partly solved this problem so that Wayfinder prints a menu like this:

          1. Parent Container Name
          1. Child Page Name
          2. Child Page Name
          3. Child Page Name

          To do this, I logged into my Linux server as root and made a backup of the wayfinder php include file:

          # cd (modx_base_path)/assets/snippets/wayfinder
          # cp wayfinder.inc.php wayfinder.inc.php.bak

          Confirmed the contents of the backup file. Then add two items to respective lines in file wayfinder.inc.php:

          ’[+wf.menuindex+]’
          '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.menuindex+]'),


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


          Make sure the new items are inserted as the last item in the arrays with proper syntax. The Wayfinder tag [+wf.menuindex+] becomes available in Wayfinder templates to print the menuindex at each level.

          The parent’s menuindex is not part of the Document Object Model so the php code to make this a wayfinder tag would be more involved.