Maybe I’m missing something, but I just spent an hour trying to determine how to get TVs to show in a getResources chunk. So if my TV is called "example" I thought the syntax would be [[*example]], but with getResources you use [[+tv.example]], and you also have to add &includeTVs=`1` &processTVs=`1` in the snippet call. This doesn’t make sense to me and it’s not documented adequately, so maybe this post will help someone else.
check! just helped me ... thanks.
-
☆ A M B ☆
- 197 Posts
It is documented here:
http://rtfm.modx.com/display/ADDON/getResources
And it does make sense. Checking for TV’s makes the whole thing slower. So if you don’t need TV’s in a resource listing you can omit the includeTV value and your getResource call will generate faster.
processTV isn’t always needed by the way.
Nomark, I didn’t say it wasn’t documented, just that it wasn’t documented adequately. I can’t see where it says you use a plus sign instead of an asterisk -- I found that by trial and error. The part that doesn’t make sense is why the syntax is different, not that there is an option to include or not include TVs.
-
☆ A M B ☆
- 24,524 Posts
The + sign is for placeholders. A placeholder is a value generated by the snippet involved, since the snippet is processing each resource and needs to insert the required values for each resource into the tpl as it loops through the list of resources.
The * is for TVs (and resource values like pagetitle) for the current resource - in this case, the resource with the getResources (or Ditto) call; it is inserted by the MODx parser itself.
If you were to use * in the getResources tpl, it would use the value for the current resource that MODx is parsing (the one with the getResources call on it), and not the individual values for the resources getResources is looping through.
So if you have resource #43 with the getResources call on it, * will always refer to the value associated with resource #43. If the getResources snippet is dealing with resources #56-#59, then + will refer to the value for each of those resources in turn as getResources loops through them.
Same for me. I could get it to work, until I found this page.
Maybe somebody can put Suzan’s post in the documentation. I think it would make sense to a lot of users.
Regards
Quote from: Rainman51 at Nov 12, 2010, 05:12 AM
Same for me. I could get it to work, until I found this page.
Maybe somebody can put Susan’s post in the documentation. I think it would make sense to a lot of users.
Regards
Done.
-
☆ A M B ☆
- 24,524 Posts
I should start keeping track of how many times I post that explanation of the difference between [*...*] and [+...+] in Ditto or other similar snippets! Of course, I had to get bitten by it once or twice myself before I finally caught on