Using pdoResources to generate a select/option dropdown

I am trying to create a select/option dropdown for a table to filter by Year (TV author-year). Each year should only appear once in the option list.

I am using the following code:

<select>
    
    [[pdoResources?
        &parents=`1206`
        &depth=`0`
        &tpl=`@INLINE <option value="[[+author-year]]">[[+author-year]]</option>`
        &includeTVs=`author-year`
        &tvPrefix=``
        &limit=`0`
        &groupby=`author-year`
        &sortby=`author-year`
        &sortdir=`DESC`
    ]]

</select>

With &groupby set I get an empty select.

Without &groupby the select is populated but each year appears multiple times.

I have done this in the past (years ago) but I cannot remember how I did it.

Any help is greatly appreciated.

Roy

I think the problem is with the TV name. author-year contains a hyphen (-). If possible, try changing the name → e.g. author_year.


When you add &showLog=`1` to the properties, you can temporarily output debug information with the [[+pdoResourcesLog]] placeholder.

[[pdoResources?
    ...
    &showLog=`1`
]]
    
<pre>[[+pdoResourcesLog]]</pre>

When testing, I get the error message “Could not process query […]: Unknown column ‘author’ in ‘group statement’” which I suspect is because of the hyphen.


Maybe this fixes the issue as well (but is kind of ugly):

[[!pdoResources?
    ...
    &groupby=``author-year``
]]

Thank you so much. It was the hyphen!!

Roy

This topic was automatically closed 2 days after discussion ended and a solution was marked. New replies are no longer allowed. You can open a new topic by clicking the link icon below the original post or solution and selecting “+ New Topic”.