Author: weaverryan
Date: 2010-02-08 01:02:04 +0100 (Mon, 08 Feb 2010)
New Revision: 27684
Modified:
plugins/sfSympalTagsPlugin/branches/1.4/lib/model/doctrine/PluginsfSympalTagTable.class.php
plugins/sfSympalTagsPlugin/branches/1.4/modules/sympal_tags/templates/_blog_popular_tags.php
Log:
[1.4][sfSympalTagsPlugin][1.0] Adding a table method to return Content objects
matching a certain type. The blog-specific tag list now hooks up to a module on
sfSympalBlogPlugin that matches blogs by tags.
I'm walking a fine-line in exactly which functionality should go in which
plugin - trying to add the code where it should go and effectively have it be
"activated" by the presence of the dependent plugin.
Modified:
plugins/sfSympalTagsPlugin/branches/1.4/lib/model/doctrine/PluginsfSympalTagTable.class.php
===================================================================
---
plugins/sfSympalTagsPlugin/branches/1.4/lib/model/doctrine/PluginsfSympalTagTable.class.php
2010-02-07 23:19:19 UTC (rev 27683)
+++
plugins/sfSympalTagsPlugin/branches/1.4/lib/model/doctrine/PluginsfSympalTagTable.class.php
2010-02-08 00:02:04 UTC (rev 27684)
@@ -92,20 +92,22 @@
* 'tag' => 5,
* );
*
- * @param string $model The name of the ContentType )e.g. sfSympalBlogPost
- * @param integer $num The number of tags to return
+ * @param string $contentType The name of the ContentType (e.g.
sfSympalBlogPost)
+ * @param integer $num The number of tags to return
*/
- public function retrieveTagsForContentType($model, $num = null)
+ public function retrieveTagsForContentType($contentType, $num = null)
{
$q = Doctrine_Core::getTable('sfSympalTag')->createQuery('t')
->select('t.name, count(t.name) count')
->innerJoin('t.ContentTags ct')
->innerJoin('ct.Content c')
- ->innerJoin('c.'.$model.' p')
->innerJoin('c.Type t2')
+ ->where('t2.name = ?', $contentType)
->orderBy('count DESC')
->groupBy('t.name');
+ $q = Doctrine_Core::getTable('sfSympalContent')->addPublishedQuery('c',
$q);
+
if ($num !== null)
{
$q->limit($num);
@@ -121,4 +123,30 @@
return $tags;
}
+
+ /**
+ * Returns a collection of sfSympalContent objects for the given
+ * content type that match the given tag
+ *
+ * @param string $contentType The name of the content type (e.g.
sfSympalBlogPost)
+ * @param string $tag A string tag to match on the content objects
+ */
+ public function retrieveContentByTag($contentType, $tag)
+ {
+ $q = Doctrine_Core::getTable('sfSympalContent')->createQuery('a')
+ ->from('sfSympalContent a')
+ ->innerJoin('a.ContentTags ct')
+ ->innerJoin('ct.Tag t')
+ ->innerJoin('a.Type t2')
+ ->where('t2.name = ?', $contentType)
+ ->andWhere('t.name = ?', $tag);
+
+ $q = Doctrine_Core::getTable('sfSympalContent')->addPublishedQuery('a',
$q);
+
+ $pager = new sfDoctrinePager('sfSympalContent',
sfSympalConfig::get('rows_per_page'));
+ $pager->setQuery($q);
+ $pager->init();
+
+ return $pager;
+ }
}
\ No newline at end of file
Modified:
plugins/sfSympalTagsPlugin/branches/1.4/modules/sympal_tags/templates/_blog_popular_tags.php
===================================================================
---
plugins/sfSympalTagsPlugin/branches/1.4/modules/sympal_tags/templates/_blog_popular_tags.php
2010-02-07 23:19:19 UTC (rev 27683)
+++
plugins/sfSympalTagsPlugin/branches/1.4/modules/sympal_tags/templates/_blog_popular_tags.php
2010-02-08 00:02:04 UTC (rev 27684)
@@ -1,6 +1,6 @@
<h3>Tags</h3>
<ul>
<?php foreach ($tags as $tag => $postCount): ?>
- <li><?php echo $tag ?> (<?php echo $postCount ?>)</li>
+ <li><?php echo link_to(sprintf('%s (%s)', $tag, $postCount),
'@sympal_blog_tag?tag='.$tag) ?></li>
<?php endforeach; ?>
</ul>
\ No newline at end of file
--
You received this message because you are subscribed to the Google Groups
"symfony SVN" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/symfony-svn?hl=en.