We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 53312
    • 6 Posts
    Hi, I wonder how to define template for each level in pdoMenu params if I want to make multilevel menu on my webpage?
    For example the structure for menu is something like this:
    <ul>
      <li>
        <div></div>
        <img src="assets/img/1.png" />
        <a>Link 1</a>
        <ul>
          <li>
            <a>Sub link 1</a>
          </li>
          <li>
            <a>Sub link 2</a>
          </li>
        </ul>
      </li>
      <li>
        <div></div>
        <img src="assets/img/2.png" />
        <a>Link 2</a>
        <ul>
          <li>
            <a>Sub link 1</a>
          </li>
          <li>
            <a>Sub link 2</a>
          </li>
        </ul>
      </li>
    </ul>
    

    So, there is no problems if structure is identical for each level. However as you can see in my case first level of menu contains img and div tags but second level does not.
    That is why I need to define different templates for each level via pdoMenu. Unfortunately, there is no comprehensive example for pdoMenu parameters. It seems that pdoMenu provides this feature only for "&levelClass" parameter which gives incrementation for css class for each level but it is not very usefull for my case.

    May be I should use some other approach for this purpose? Pdoresources or getresources? Somebody please help me.
      • 53312
      • 6 Posts
      Still believe that it is possible to solve such a simple problem throug base modx tools.
        • 4172
        • 5,888 Posts
        there are the different Template Properties and the [[+level]] - placeholder, where you can play with

        https://docs.modx.pro/en/components/pdotools/snippets/pdomenu


          -------------------------------

          you can buy me a beer, if you like MIGX

          http://webcmsolutions.de/migx.html

          Thanks!
          • 53312
          • 6 Posts
          Quote from: Bruno17 at Mar 15, 2017, 07:37 AM
          there are the different Template Properties and the [[+level]] - placeholder, where you can play with

          https://docs.modx.pro/en/components/pdotools/snippets/pdomenu


          Sorry, but there is nothing about [[+level]] placeholder. Unfortunately, docs are insufficient. Nothing to play with in this case.
          So, even if we have [[+level]] placeholder then it is not very useful, cuz this outputs only number of level.
          The main problem - we can define template once and it is identical for each level and it seems that there is no way to change templates depending on the level.

          So simple question. So difficult to solve.
            • 4172
            • 5,888 Posts
            No need to be sorry. Simple question, simple to solve (if you are smart enough)

            &tpl, &tplParentRow and &tplInnerRow should be enough, to solve your question.
            If not, you can use the [[+level]] placeholder with outputfilters

            An example of one of my parentRow - chunks:

            [[+level:is=`1`:then=`
            <li[[+classes]]><a href="[[+link]]" class="nav-link dropdown-toggle" data-toggle="dropdown" data-hover="dropdown" role="button" aria-expanded="false" [[+attributes]]>[[+menutitle]]</a>[[+wrapper]]</li>
            `:else=`
            <li[[+classes]]><a href="[[+link]]" class="nav-link" [[+attributes]]>[[+menutitle]]</a>[[+wrapper]]</li>
            `]]


              -------------------------------

              you can buy me a beer, if you like MIGX

              http://webcmsolutions.de/migx.html

              Thanks!
              • 53312
              • 6 Posts
              Quote from: Bruno17 at Mar 15, 2017, 12:06 PM

              An example of one of my parentRow - chunks:
              Thank you for your help. Admittedly, it was simple. I have already implemented my own solution to this problem through custom snippet because some extra features were needed (for e.g. affect parent if child selected).
                • 37104
                • 19 Posts
                The guidance from Bruno17 on this really helped me figure out a workable solution to a 3-level Bootstrap 3 menu. I replied to another thread with details of what I did, as my use case was more in line with what the other poster was looking to achieve.

                My approach to a 3-level Bootstrap 3 menu in MODx using pdoMenu and the advice from Bruno17:
                https://forums.modx.com/thread/101651/trouble-with-multi-level-menu-with-bootstrap#dis-post-559478
                  The older I get, the faster I was.

                  http://www.evanchute.com/