Hello,
I’m building a wine tastingnote website and I want to get a distinct list of all countries, regions, appellations etc. I was hoping that pdoResources would be able to do it, but I can’t get it to work and I have a really hard time to find any examples or proper documentation… I think it is possible to use &groupBy as it is being presented as a generic pdoTools option, but I do not know how to refer to the column I want it grouped by… So to be clear I want to have a “select distinct” on e.g. the winecountry column.
Here’s an example: give me a list of all countries used in my tasting notes:
[[pdoResources?
&parents=34
&depth=0
&tpl=@INLINE <li>[[+tv.tn-winecountry]]</li>
&includeTVs=tn-winecountry
&limit=100
&groupBy=tn-winecountry
&showLog=1
&sortby={“tn-winecountry”:“ASC”}
]]
What am I doing wrong?
Thanks so much --Mike
PS pdoResources seems to work just fine with close to 9000 tasting notes. Simplesearch is a bit slower but still not too bad. When everything’s set up correctly I’ll report back on behavior of a lot of resources, as I have the impression that that information is missing a bit --M.
This property has to be written with a lower case b
(–> &groupby
) to be processed.
Also, when I test it, there seems to be a problem with the dot (.
) in the TV prefix and the dash (-
) in the TV-name as well.
You can avoid the TV prefix by setting the property &tvPrefix
to empty.
[[!pdoResources?
...
&tpl=`@INLINE <li>[[+tnWinecountry]]</li>`
&groupby=`tnWinecountry`
&tvPrefix=``
]]
1 Like
@halftrainedharry you’re the best. This was indeed the solution… I did not realise that a dash might pose problems?
Changed the dashes of all of my TV’s to underscores - not a big fan of CamelCasing, as the groupBy/groupby error shows
Thanks again, I would have given up.
Cheers --Mike
In order to help anyone looking for this solution and to compensate the lack of examples in the pdoResources documentation, this works:
[[pdoResources?
&parents=3
&tvPrefix=``
&showLog=1
&depth=0
&tpl=@INLINE <li>[[+tg_location]]</li>
&includeTVs=tg_location
&groupby=tg_location
&limit=0
&sortby={“tg_location”:“ASC”}]]
So critical to remember is:
- Include &tvPrefix=`` in order to avoid confusion with the dot (.) for pdoResources. It does not work without this statement - it cannot process tv.tg_location but works with this statement and thus tg_location
- Avoid dashes (-) in your TV names: I’ve used underscores (_)
Cheers --Mike
1 Like