We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 21872
    • 95 Posts
    My Google skills may be failing, or perhaps this should be obvious, but I’m unable to find any information on implementing taxonomies in revolution. Ideally, it would be possible to display a list of all resources that share have a common tag (or combination of tags). Does anyone know what how this should be implemented?

    I apologize if this has been answered elsewhere.

    Related, (and this may be another instance of imbecility on my part) I’d like to be able to generate a list of all child resources by entering the path to a container. For example, if containername has three children, entering mysite.com/containername/ would display a list of them.

    Thank you.
      • 3749
      • 24,544 Posts
      To answer your second question, you could do it fairly easily with just the name of the container (assuming that you have no duplicate container names):

      
      $resource = $modx->getObect(array('pagetitle'=>'name_of_your_container'));
      
      $children = $modx->getChildIds($resource->get('id'));


      $children will be an array containing the ids of the children. If you’d like an array containing the child objects themselves, you’d use this in place of the second line:

      $resource->getMany('Children');
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 22295
        • 153 Posts
        Quote from: nsfdev at Apr 10, 2010, 10:03 PM

        Ideally, it would be possible to display a list of all resources that share have a common tag (or combination of tags). Does anyone know what how this should be implemented?

        If I understood your question correctly, lets assume your tags are in a ’tags’ tv.

        $tvObj = $modx->getObject('modTemplateVar',array('name'=> 'tags')); 
        $tvs = $tvObj->getMany('TemplateVarResources',array('value' => 'someTag'));
        // OR THIS one, is the same:  $tvs = $modx->getCollection('modTemplateVarResource',array('tmplvarid' => $tvObj->get('id'), 'value' => 'someTag'));
        
        foreach ($tvs as $tv) {
        $resourceId = $tv->get('contentid');
        // ... all the rest of you code...
        }



        for more complex queries define an xPDOCriteria instead of the simple array(’value’=>’someTag’)
        note: i haven’t tested the above code, but it should work..
          • 22303 MODX Staff
          • 10,725 Posts
          See the getResources snippet; it has TV filtering options that are infinitely more efficient at this kind of query.
            • 21872
            • 95 Posts
            Thank you, I’ll have to spend some time with that.