We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 37909
    • 153 Posts
    Hi!

    I use Articles. I have a navigation column to filter all the articles by tags, dates and authors.

    To display the list of authors, I use this simple code:
    [[!getResources?
    	&parents=`15`
    	&tpl=`articles.authors`
    	&showHidden=`1`
    ]]


    But, this solution have a big problem. If a author writes several articles, he will be displayed several times.

    How can I display each author only once?

    This question has been answered by multiple community members. See the first response.

      • 28042 ☆ A M B ☆
      • 24,524 Posts
      I would use an auto-tag TV for that. Then you can use the TagLister snippet to output your list.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 37909
        • 153 Posts
        Articles uses “Created By”. It's a shame to use multiple TV for that, isn't it?
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          Well, if you ask my opinion (which you didn't, I know) it's a shame you're using Articles in the first place.

          I'm sure there is some way you can get the created by IDs using a Group By clause, then get the users' names.

            Studying MODX in the desert - http://sottwell.com
            Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
            Join the Slack Community - http://modx.org
            • 37909
            • 153 Posts
            No offense sottwell. “It's a shame”: I mean, it's too bad… You know what I mean?

            So, what is the alternative to Articles?
            • discuss.answer
              • 37909
              • 153 Posts
              You're right sottwell. I modify the getRessoures snippet.

              Add line 125:
              $groupby = isset($groupby) ? $groupby : '';


              Add line 354:
              /* New code */
              if (!empty($groupby)) {
              	$criteria->groupby($groupby);
              }
              /* End of new code */
              if (!empty($where)) {
                  $criteria->where($where);
              }


              Very simple but it's work!

              And, of course, the snippet call:
              [[!getResources?
              	&parents=`15`
              	&tpl=`articles.authors`
              	&showHidden=`1`
              	&groupby=`createdby`
              ]]
              • discuss.answer
                • 28042 ☆ A M B ☆
                • 24,524 Posts
                pdoTools, and its included snippet pdoResources, includes a groupby property already. http://docs.modx.pro/en/components/pdotools/general-settings
                  Studying MODX in the desert - http://sottwell.com
                  Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                  Join the Slack Community - http://modx.org
                  • 37909
                  • 153 Posts
                  Quote from: sottwell at Oct 15, 2015, 10:24 AM
                  pdoTools, and its included snippet pdoResources, includes a groupby property already. http://docs.modx.pro/en/components/pdotools/general-settings
                  Do you mean that I did something it's already did?
                    • 28042 ☆ A M B ☆
                    • 24,524 Posts
                    Not with getResources - or at least not as far as I know. pdoResources is another matter. And that's why I've been installing pdoTools and using its various listing snippets (pdoMenu, pdoUsers, pdoResources etc) for years.
                      Studying MODX in the desert - http://sottwell.com
                      Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                      Join the Slack Community - http://modx.org
                      • 37909
                      • 153 Posts
                      Quote from: sottwell at Oct 15, 2015, 10:48 AM
                      Not with getResources - or at least not as far as I know. pdoResources is another matter. And that's why I've been installing pdoTools and using its various listing snippets (pdoMenu, pdoUsers, pdoResources etc) for years.

                      I see. It looks very good. Thanks.