getResources displays all subdirectories - modx

In modx I have a resource that goes two folders deep. I'm trying to only display the resources in the parent directory (not the resources in its subdirectories). My getResources call is in the parent resource and reads:
[[!getResources?
&parents=`[[*id]]`
&showHidden=`1`
&includeContent=`1`
&includeTVs=`1`
&processTVs=`1`
&tvPrefix=``
&limit=`0`
&tpl=`Attractions Section`
&sortby=`menuindex`
&depth=`1`
]]
As far as I understand it, the depth parameter should control how deep gr goes to display its resources. I've set depth to 0 and 1, and it's still displaying all the resources in the subdirectories. How do I get it to only display the current directory's resources?

I've had problems with getResources before and the ~order~ of things ~if~ one of your other attrib values is incorrect, it may be ignoring subsequent attributes. so to start get rid of any that you are not using or do not actually need [tvprefix, sortby is menuindex by default I think] then move depth right up to under parents.
Also I've always treated modx chunk, snippet, TV & template names as variables, i.e. 'no spaces or weird characters' I really don't know if it matters or not, but your tpl name looks suspicious.
But yes, you are right &depth=0 should only be selecting the first level of resources.

Got it. depth=`depth` returns first level of resources below parent ModX Docs.

Related

Wayfinder IncludeDocs parameter in Modx is breaking the snippet

I'm quite stuck on an unexpected problem. I'm trying to use Wayfinder to generate a sitemap for a project. The output of the navigation items is as expected, but I need to include a number of documents in addition to the primary navigation elements.
To do this, I have used the includeDocs parameter.
[[Wayfinder? &startId=`0` &includeDocs=`17,18,19,20`]]
When I do this, I get no output at all. Remove includeDocs and I get the standard nav (expected). Use the param and the output is completely empty.
No idea what I'm doing wrong or what (if any) other setting must be defined in order to make this work.
The includeDocs parameter is very misleading. It should rather be named "onlyIncudeDocs" or "restrictTo", since that is what it does. It also requires the docs you include to be directly accessable from your startId, alternatively have the entire path "included".
I would suggest you create weblink resources directly under your startId, and link them to the resources you want to include. That way wayfinder will pick them up by default. (Note that you may need to handle this in your rowTpl for wayfinder, since a weblink stores the actual link in it's content field)
If you also want to include the children of the id's you specify, you would probably be better of slightly revising your resource structure.

Modx Rev - Manager not showing all documents in list

I have worked with ModX for a while, but can't seem to sort this issue. When I login as the admin in to the manager, the resources list is incomplete with not all documents displaying. I can however locate the files via the 'search' area just above.
I have done the normal, empty cache, flush permissions etc. without any joy. Interesting enough its always the same files, and they are showing in the front end.
Any help welcome on this one!
Update
When I click the blog (which is an articles resource) only the template variables panel is showing, nothing else. Page looks a little broken...
Update 2
If i remove the blog, (articles) the pages show. And... If I move the articles container higher, all resources show.
Are you using multiple contexts? I've noticed this behaviour a few times when drag and dropping folders with nested resources from one context to folder in another context.
Moving them back to the original context made them re-appear.
If you're familiar with MySQL GUIs like phpMyAdmin you could check and search the *modx_site_content* table and maybe correct the value in the resources' parent field manually. As Mark said it might well be a parent gone MIA.
Typically, parents rarely go MIA and by that I mean once every couple years....
Did you set up ACLs or Resource Groups?
Is your manager user a member of those groups?

How to re-order weblinks in ModX

Currently on our site we have 4 weblink resources that are displaying in proper order (by the date on the title) on the page, but after adding one more weblink resource, it is added to the page but appears one below the first link, when it should be at the top.
I am not sure where to look to manually re-order these, and there doesn't seem to be any option to do this from the ModX interface or Resource Edit menu (setting the "index" does nothing).
Is there a way to accomplish this? Is it possible that this is custom and I need to find where the ordering is happening? I have looked in the Snippets folder for this page and wasn't able to find anything that looked like it was doing ordering.
Possibly related noob question: If we just want to manually re-order the links via html, how do we modify the source code directly, via ModX?
If you are using a custom snippet to extract the links then modx will not be doing any ordering for you at all, that would need to be written into the snippet itself.
if you are using getResources, [ http://rtfm.modx.com/display/ADDON/getResources ] look up the sortby option in the docs. I'm not 100% sure what the default is.
if you are using WayFinder [ http://rtfm.modx.com/display/ADDON/Wayfinder ] the default sort order will be the order they appear in the resource tree, which I believe is menuindex. I believe WayFinder also has a sorting option. [see the docs]
if you are not seeing changes when moving things around in the resource tree, be sure to clear the cache as changes in the resource tree do not automatically refresh the cache.
to manually add the links into the page/resource, you need to find the chunk/snippet/template that is displaying the links and modify that accordingly.
To manually re-order resources in "Resources Tree" you just need "drag-and-drop" by mouse to change the resources places.

ModX Revo: Display one resource within another

I want to display the contents of one resource within another. I think this is possible with getResources but I cannot get it working for me. I have:
[[getResources &parents=`-1` $resources =`16`]]
but nothing displays. I have made sure all resources have been published and that getResources is installed correctly.
Can anyone point me in the right direction?
Thanks
Yes - that's exactly what getResources is for, you are not getting anything because you have a few syntax errors.
[[getResources &parents=-1 $resources =16]]
should be:
[[getResources? &parents=-1 &resources =16 &tpl=myTpl]]
the '?' tells Modx that there will be parameters, $resources will get ignored & if you don't specify an &tpl parameter, getResources will just dump the raw array to your page.
Actually there is no need to use a template. This code is working fine:
[[getResources? &resources=1 &tpl=#INLINE [[+content]] &includeContent=1 ]]

Get count of items in a velocity list

I'm creating a set of custom templates and structures for a Liferay site.
One structure provides for a repeatable section, which its matching template then iterates over.
However, for styling reasons, I need to know how many instances of the repeatable section are actually present, and I need to know before I loop.
So, the template code is something like this:
#foreach($thisChunk in $chunk.getSiblings())
[emit some HTML]
#end
I want to do some conditional logic before the foreach, and emit a different CSS classname on the containing element depending on how many $chunks there are.
Any ideas how to access the number of siblings without looping through them first?
Easy: $chunk.getSiblings().size()
How to find out? It's a plain old Java object (java.util.ArrayList in my quick test). You can find this out when you just temporarily debug your template with $chunk.getSiblings().getClass().getName() and then continue with the interface of that class.

Resources