We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 38366
    • 2 Posts
    Hey guys,
    Is there a way to generate a list of articles by tag?

    E.g. I want to list all articles with the tag "residential".
      • 40728
      • 29 Posts
      I'm wondering the same thing as well. The Articles documentation and the "Creating a blog in Revolution[/url]" lightly touch the subject, and as far as I understand, only on listing an articles tag(s).

      In Articles, there is a field for blog posts called tags, yet when I look at the raw Array output, the tags are nowhere to be found.

      Like mattiboi89, I'm simply looking for a way to filter getResources on tags.
        • 36447
        • 98 Posts
        Maybe I'm misunderstanding your posts, but this link discusses retrieving of posts using tags: https://forums.modx.com/thread/78602/retrieve-articles-outside-of-articles-by-tag#dis-post-433248
          • 40728
          • 29 Posts
          Well it works, but that's a terribly inelegant solution.

          Thanks anyway, puffin2!
            • 37131
            • 111 Posts
            Articles has built-in support for tags and it's kind of working. You have to fix some bugs, more or less, depends on if you want to use Friendly URLs
              ---
              Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live. Martin Golding
              • 36447
              • 98 Posts
              By terming it such, I'm not sure what you expect; you have to make a getResources snippet call to retrieve posts labeled with tags and that's about as simple as it gets.

              Making a call based on a single tag is pretty easy; it's when you get into multiple tags that the problems begin to multiply. Tags are stored in a separate table in the db as strings separated by commas, so when characters overlap, you're forced to be creative in order to render the results you want. We need the modx team to come up with a better solution for multiple tags.
                • 28042 ☆ A M B ☆
                • 24,524 Posts
                Actually this is a function of the add-on in question; MODx itself has nothing to do with it.
                  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
                  • 36447
                  • 98 Posts
                  Susan, not sure what you mean exactly. Didn't the team develop Articles? Regardless who developed it, it seems that retrieving posts using tags is pretty limited in its present iteration.
                    • 38366
                    • 2 Posts
                    Hey guys.
                    I'm not really a programmer I just read a few articles and mucked around a bit.
                    I worked out a way to Display a list of articles for multiple tags with get resources
                    You can make an array $blog_tag_search with all the tags you want to search (I did it this way cause my array is dynamic)


                    Eg

                    $blog_tag_search[0] = 'blabla';
                    $blog_tag_search[1] = 'tag2';

                    // this next part builds the search string to search the template variables using get resources
                    foreach($blog_tag_search as $listing) {
                    $tag_listing .= "'".$listing."' ";
                    $getResources_params['tvFilters'] .= "articlestags==%$listing%||";
                    }

                    /* this next part removes the last two || symbols to makes the tvfilters parameter valid */
                    $getResources_params['tvFilters'] = substr($getResources_params['tvFilters'],0,-2);
                    //echo $getResources_params['tvFilters'];

                    $getResources_params['includeContent'] = '1';
                    $getResources_params['includeTVs'] = '1';

                    //HERE IS YOU GET RESOURCES TEMPLATE FILE
                    $getResources_params['tpl'] = '2012_overview_articles_list';
                    $getResources_params['showHidden'] = '1';
                    $getResources_params['limit'] = '0';
                    $getResources_params['sortby'] = '{"pagetitle":"ASC"}';

                    // CHANGE TO THE ID OF YOUR "articles" PAGE (parent of your articles)
                    $getResources_params['parents'] = '591';
                    $output = $modx->runSnippet('getResources',$getResources_params);

                    //if there is output (i.e. a list) set the placeholder
                    if($output) {
                    return $output;
                    }