From 843e4295981d9295bb58360d8a90f2afe370e45e Mon Sep 17 00:00:00 2001 From: Matt La France Date: Mon, 20 Feb 2012 16:05:13 -0500 Subject: [PATCH 1/2] Add configurable comments link to the news module. If you'd like to provide a link back to the comments form on individual news articles, you can now add SHOW_COMMENTS_LINK = 1 to the feed in the news module's feeds.ini file. This is just like the SHOW_LINK option that provides a link to "Read More". This provides an additional link that says "Leave/Read Comments" (configurable in the strings.ini file). --- app/modules/news/NewsWebModule.php | 4 ++++ app/modules/news/strings/en_US.ini | 1 + app/modules/news/templates/story.tpl | 5 +++++ 3 files changed, 10 insertions(+) diff --git a/app/modules/news/NewsWebModule.php b/app/modules/news/NewsWebModule.php index 0a098fefc..7e77363a4 100644 --- a/app/modules/news/NewsWebModule.php +++ b/app/modules/news/NewsWebModule.php @@ -25,6 +25,7 @@ class NewsWebModule extends WebModule { protected $showPubDate = false; protected $showAuthor = false; protected $showLink = false; + protected $showCommentsLink = false; public static function validateFeed($section, $feedData) { if (!self::argVal($feedData, 'TITLE')) { @@ -178,6 +179,7 @@ protected function initialize() { $this->showPubDate = isset($feedData['SHOW_PUBDATE']) ? $feedData['SHOW_PUBDATE'] : false; $this->showAuthor = isset($feedData['SHOW_AUTHOR']) ? $feedData['SHOW_AUTHOR'] : false; $this->showLink = isset($feedData['SHOW_LINK']) ? $feedData['SHOW_LINK'] : false; + $this->showCommentsLink = isset($feedData['SHOW_COMMENTS_LINK']) ? $feedData['SHOW_COMMENTS_LINK'] : false; } protected function htmlEncodeFeedString($string) { @@ -234,8 +236,10 @@ protected function initializeForPage() { $this->assign('author', $this->htmlEncodeFeedString($story->getAuthor())); $this->assign('image', $this->getImageForStory($story)); $this->assign('link', $story->getLink()); + $this->assign('commentslink', $story->getComments()); $this->assign('ajax', $this->getArg('ajax')); $this->assign('showLink', $this->showLink); + $this->assign('showCommentsLink', $this->showCommentsLink); break; case 'search': diff --git a/app/modules/news/strings/en_US.ini b/app/modules/news/strings/en_US.ini index d249285b5..434f1f46b 100644 --- a/app/modules/news/strings/en_US.ini +++ b/app/modules/news/strings/en_US.ini @@ -10,6 +10,7 @@ NEXT_STORY_TEXT="Next %s stories" SECTION_TEXT="Section:" NO_RESULTS="No Stories Found" READ_MORE="Read More" +READ_COMMENTS="Read/Leave Comments" AUTHOR_CREDIT="by %s" NEWS_ADMIN_OPTIONS_TITLE="Options" NEWS_ADMIN_OPTIONS_DESCRIPTION="" diff --git a/app/modules/news/templates/story.tpl b/app/modules/news/templates/story.tpl index 06230b6de..c993b8156 100644 --- a/app/modules/news/templates/story.tpl +++ b/app/modules/news/templates/story.tpl @@ -39,6 +39,11 @@ {"READ_MORE"|getLocalizedString} {/if} + {if $showCommentsLink} +
+ {"READ_COMMENTS"|getLocalizedString} +
+ {/if} From bc525389fadeaf78228e3be4b95f5e28133845ee Mon Sep 17 00:00:00 2001 From: Matt La France Date: Mon, 20 Feb 2012 16:18:38 -0500 Subject: [PATCH 2/2] If there is no "comment" in feed, comments link uses "link". --- app/modules/news/NewsWebModule.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/modules/news/NewsWebModule.php b/app/modules/news/NewsWebModule.php index 7e77363a4..162dc6362 100644 --- a/app/modules/news/NewsWebModule.php +++ b/app/modules/news/NewsWebModule.php @@ -236,7 +236,12 @@ protected function initializeForPage() { $this->assign('author', $this->htmlEncodeFeedString($story->getAuthor())); $this->assign('image', $this->getImageForStory($story)); $this->assign('link', $story->getLink()); - $this->assign('commentslink', $story->getComments()); + if ($story->getComments()) { + $this->assign('commentslink', $story->getComments()); + } + else { + $this->assign('commentslink', $story->getLink()); + } $this->assign('ajax', $this->getArg('ajax')); $this->assign('showLink', $this->showLink); $this->assign('showCommentsLink', $this->showCommentsLink);