Is there any sytem-tv which contains the current highest resource-id?
Something like:
[[*idmax]]
or
[[++idmax]]
Does anybody know this?
-
☆ A M B ☆
- 24,524 Posts
You can use getResources or pdoResources
[[pdoResources? &parents=`0` &orderby=`id` &limit=`1` &tpl=`@CODE [[+id]]` ]]
[ed. note: sottwell last edited this post 12 years, 4 months ago.]
you might need additional properties, to show also unpublished resources and resources, which are hidden from menue
should be the same, as used with getResources
http://rtfm.modx.com/extras/revo/getresources#getResources-OtherProperties
Hi Bruno,
much better!! But there are still missing a couple. Maybe we have to clear the cache to get also the newest resources? Or is this method independently of the cache?
I think wands' method above would bypass the cache, as would this (untested):
$c = $modx->newQuery('modResource');
$c->sortby('id', 'DESC');
$c->limit(1);
$resources = $modx->getCollection('modResource', $c);
return reset($resources)->id;
[ed. note: BobRay last edited this post 12 years, 4 months ago.]