Author: weaverryan
Date: 2010-02-08 01:11:54 +0100 (Mon, 08 Feb 2010)
New Revision: 27685
Modified:
plugins/sfSympalBlogPlugin/branches/1.4/config/routing.yml
plugins/sfSympalBlogPlugin/branches/1.4/modules/sympal_blog/lib/Basesympal_blogActions.class.php
Log:
[1.4][sfSympalBlogPlugin][1.0] Adding a module to handle the listing of posts
that match a specific tag. This hooks in naturally with sfSympalTagsPlugin.
Modified: plugins/sfSympalBlogPlugin/branches/1.4/config/routing.yml
===================================================================
--- plugins/sfSympalBlogPlugin/branches/1.4/config/routing.yml 2010-02-08
00:02:04 UTC (rev 27684)
+++ plugins/sfSympalBlogPlugin/branches/1.4/config/routing.yml 2010-02-08
00:11:54 UTC (rev 27685)
@@ -2,4 +2,10 @@
sympal_blog_month:
url: /blog/:m/:y
- param: { module: sympal_blog, action: month }
\ No newline at end of file
+ param: { module: sympal_blog, action: month }
+ requirements:
+ m: \d+
+ y: \d+
+sympal_blog_tag:
+ url: /blog/tags/:tag
+ param: { module: sympal_blog, action: tag }
\ No newline at end of file
Modified:
plugins/sfSympalBlogPlugin/branches/1.4/modules/sympal_blog/lib/Basesympal_blogActions.class.php
===================================================================
---
plugins/sfSympalBlogPlugin/branches/1.4/modules/sympal_blog/lib/Basesympal_blogActions.class.php
2010-02-08 00:02:04 UTC (rev 27684)
+++
plugins/sfSympalBlogPlugin/branches/1.4/modules/sympal_blog/lib/Basesympal_blogActions.class.php
2010-02-08 00:11:54 UTC (rev 27685)
@@ -10,12 +10,15 @@
*/
abstract class Basesympal_blogActions extends sfActions
{
- public function executeMonth($request)
+ /**
+ * An action that filters posts by year and month
+ */
+ public function executeMonth(sfWebRequest $request)
{
$month = $request->getParameter('m');
$year = $request->getParameter('y');
- $this->menuItem =
Doctrine::getTable('sfSympalMenuItem')->findOneBySlug('blog');
+ $this->menuItem = $this->getBlogMenuItem();
$this->pager =
Doctrine::getTable('sfSympalBlogPost')->retrieveBlogMonth($month, $year);
$this->content = $this->pager->getResults();
@@ -25,4 +28,37 @@
$this->setTemplate('list');
}
+
+ /**
+ * An action that filters posts by tags. This requires the sfSympalTagsPlugin
+ */
+ public function executeTag(sfWebRequest $request)
+ {
+ if (!in_array('sfSympalBlogPlugin',
$this->getSympalContext()->getSympalConfiguration()->getInstalledPlugins()))
+ {
+ throw new sfException('sympal_blog/tag action requires
sfSympalBlogPlugin to be installed');
+ }
+
+ $tag = $request->getParameter('tag');
+
+ $this->menuItem = $this->getBlogMenuItem();
+ $this->pager =
Doctrine::getTable('sfSympalTag')->retrieveContentByTag('sfSympalBlogPost',
$tag);
+ $this->content = $this->pager->getResults();
+
+ $this->breadcrumbsTitle = sprintf('Posts tagged with "%s"', $tag);
+ $this->title = $this->breadcrumbsTitle;
+
+ $this->setTemplate('list');
+ }
+
+ /**
+ * Returns the default blog menu item so that the breadcrumbs can be
+ * properly rendered
+ *
+ * @return sfSympalMenuItem
+ */
+ protected function getBlogMenuItem()
+ {
+ return Doctrine::getTable('sfSympalMenuItem')->findOneBySlug('blog');
+ }
}
--
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.