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.
[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
-
☆ 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.
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
Another way to go would be a dedicated snippet, which would be a little faster:
<?php
/* ParentMenuIndex snippet */
$parent = $modx->getObject('modResource', $modx->resource->get('parent'));
if ($parent) {
return $parent->get('menuindex');
}
return '';
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 '';
-
☆ 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
That's cool. Does it survive upgrades to MODX?
If only it worked for users.
-
☆ 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.]