We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 44920
    • 48 Posts
    Hi,

    hit on an interesting nut to crack - i need to find out menuindex of parent resource.
    would something like this be possible? i'd like to use this value in getResources call:

    something like:
      &tpl=`tabsRowsTpl`
      &tpl_[[*parent.menuindex:incr]]=`tabsRowsFirstTpl`
    


    please advise

    thank you in advance
    kr.

    This question has been answered by sottwell. See the first response.

    [ed. note: krajicek last edited this post 13 years ago.]
      MODX Revolution 2.2.8-pl (advanced)

      Extras:
      archivist 1.2.4 | Articles 1.7.1 | Babel 2.2.5 | getpage 1.2.3 | getresources 1.6.0 | quip 2.3.3 | SimpleSearch 1.6.1 | taglister 1.1.7 | TinyMCE 4.3.3 | Wayfinder 2.3.3

      PHP Version 5.6.20-0
      MySQL Version 5.5.31
    • discuss.answer
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      If you installed the fastField add-on, you could indeed use
      [[#[[*parent]].menuindex]]


      Without fastField and its additional "field" tag, you'll need to use the getResourceField snippet to get the parent resource's menuindex.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 44920
        • 48 Posts
        Thank you, Susan,

        you are a star!

        kr
          MODX Revolution 2.2.8-pl (advanced)

          Extras:
          archivist 1.2.4 | Articles 1.7.1 | Babel 2.2.5 | getpage 1.2.3 | getresources 1.6.0 | quip 2.3.3 | SimpleSearch 1.6.1 | taglister 1.1.7 | TinyMCE 4.3.3 | Wayfinder 2.3.3

          PHP Version 5.6.20-0
          MySQL Version 5.5.31
          • 3749
          • 24,544 Posts
          Another way to go would be a dedicated snippet, which would be a little faster:


          [[!ParentMenuIndex]]



          <?php
          /* ParentMenuIndex snippet */
          
          $parent = $modx->getObject('modResource', $modx->resource->get('parent'));
          if ($parent) {
              return $parent->get('menuindex');
          }
          return '';
          

            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting
            • 3749
            • 24,544 Posts
            Here's a more generic snippet to get any field from the parent:



            [[!getParentField? &field=`pagetitle`]]



            <?php
            /* getParentField snippet */
            
            $parent = $modx->getObject('modResource', $modx->resource->get('parent'));
            if ($parent) {
                return $parent->get($scriptProperties[$field]);
            }
            return '';
            


              Did I help you? Buy me a beer
              Get my Book: MODX:The Official Guide
              MODX info for everyone: http://bobsguides.com/modx.html
              My MODX Extras
              Bob's Guides is now hosted at A2 MODX Hosting
              • 28042 ☆ A M B ☆
              • 24,524 Posts
              The real beauty of fastField is that it's a custom parser, actually extending the modParser, so it's just as fast as using any other ordinary MODx tag - no snippet, no plugin, no extra eval() or other processing. The ability to specify a custom parser was added in Revo 2.2.7
                Studying MODX in the desert - http://sottwell.com
                Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                Join the Slack Community - http://modx.org
                • 3749
                • 24,544 Posts
                That's cool. Does it survive upgrades to MODX?

                If only it worked for users.
                  Did I help you? Buy me a beer
                  Get my Book: MODX:The Official Guide
                  MODX info for everyone: http://bobsguides.com/modx.html
                  My MODX Extras
                  Bob's Guides is now hosted at A2 MODX Hosting
                  • 28042 ☆ A M B ☆
                  • 24,524 Posts
                  Yes, its files are in core/components/fastfield, and it's a System Setting to specify what parser to use and the path to the parser file. Of course any major changes to parser functionality would most likely break it, but then that's the case with many of the extras that depend on the API.

                  As far as quick access to user data, see the rtfm for output modifiers. [ed. note: sottwell last edited this post 13 years ago.]
                    Studying MODX in the desert - http://sottwell.com
                    Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                    Join the Slack Community - http://modx.org