Search code examples
phpsymfony1tagssymfony-1.4

Using sfDoctrineActAsTaggablePlugin, how to get the list of tags + the number of contents they tag?


PluginTagTable::getAllTagNameWithCount() gets me the list of tags, but I need to add a condition on the Contents the tags are tagged to.

How do I get the list of tags + the number of contents, where content.state_id = 3?


Solution

  • Found the answer in apostrophe plugin :

    $q = Doctrine_Query::create()->from('Tagging tg, tg.Tag t, Content c');
    $q->andWhere('c.id = tg.taggable_id and c.state_id = ?', 3);
    
    $this->tagsInOrder = PluginTagTable::getAllTagNameWithCount($q,Array('model' => 'Content', 'sort_by_popularity' => true));