We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 40833
    • 52 Posts
    I just finished creating a simple product catalog for a client using the excellent Collections (https://rtfm.modx.com/extras/revo/collections) addon. I also used the Tagger (https://rtfm.modx.com/extras/revo/tagger) addon for it’s relative ease in setup and usage. One thing I wanted to do was add a column in the Collections product list that showed the tags that were assigned to each product. It turns out, this was pretty easy.

    Step 1 - Add Column
    Go to Extras -> Collection Views and open your collection. Click the Add Column button and enter your label (I used “Categories”). For the Name, I just entered an unused field (which for this setup, happened to be “published”). Collections evidently only allows you to use each field once in the columns list.

    In the Snippet Renderer field, add the name of your snippet - I used “collections_getCategories”, but this can be anything.

    Step 2 - Create Snippet Renderer
    Create your snippet using the name you entered in the Snippet Renderer field and add the following code:
    $row = $modx->getOption('row', $scriptProperties, '');
    $tags = $modx->runSnippet('TaggerGetTags', array( 
    'rowTpl' => 'collections_taggerRowTpl',
    'resources' => $row['id']
    ) );
    
    return $tags;

    Save your snippet.

    Step 3: Create the rowTpl Chunk
    Create a chunk and name it “collections_taggerRowTpl”. Place this in the chunk:
    [[+tag]]<br />

    Save your chunk and that should be it! Hope this helps.
      • 40833
      • 52 Posts
      Just wanted to follow up with a correction to the above snippet. This code was filling up my error log with
      `0` is not a valid integer and may not be passed to makeUrl()
      due to the fact that the "target" parameter is required for TaggerGetTags. So here is the updated snippet:

      $row = $modx->getOption('row', $scriptProperties, '');
      if( !$row || empty( $row['id'] ) ) { return ''; }
      $tags = $modx->runSnippet('TaggerGetTags', array( 
      'rowTpl' => 'collections_taggerRowTpl',
      'resources' => $row['id'],
      'target' => 1 // this should point to a valid resource, doesn't matter which
      ) );
       
      return $tags;
      
      • You can now do this from within the Collections columns settings. Just add a valid Tagger group alias, prefixed with tagger_, into the Name field of your new column.
          Lucy Iannotti
          Following Sea design & development
          http://www.following-sea.com
          New Bedford, MA
          • 40833
          • 52 Posts
          Quote from: lucy at May 18, 2016, 05:39 PM
          You can now do this from within the Collections columns settings. Just add a valid Tagger group alias, prefixed with tagger_, into the Name field of your new column.

          This is good, I'm very glad that the Collections addon is being actively maintained. It's such an indispensable tool for MODx. However, I've really stopped using the Tagger addon in favor of Taxonomies due to the inflexible nature of Tagger. Taxonomies uses built-in resources which is a much more intuitive and MODx-centric way of doing it. Thanks though!
            • 36516
            • 179 Posts
            I'm DESPERATE for Taxonomies, but it won't run on my hosting environment. I had errors in the log about class autoloading etc. Others on this forum have been discussing the same, with little success. Some suggested change to the addon code which might help but I haven't got around to trying yet. I presume you were able to use it "out of the box" without issue, but if that's not the case and you had to tweak it to get it working, please explain!
              • 42766
              • 47 Posts
              Quote from: dan971 at Jan 12, 2016, 01:41 PM
              'target' => 1 // this should point to a valid resource, doesn't matter which
              

              Thanks for this - you just saved my logs MBs and MBs of redundant entries!
                • 46580
                • 167 Posts
                Quote from: lucy at May 18, 2016, 12:39 PM
                You can now do this from within the Collections columns settings. Just add a valid Tagger group alias, prefixed with tagger_, into the Name field of your new column.

                Is there also a custom editor to display listbox populated with tagger tags ?
                  MODX lover
                  -
                  Développeur MODX / Webdesign / Solutions web