Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Archive

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, biapar, Willr, Ingo, simon_w

Blog - show full post


Go to End
Reply

9 Posts   3639 Views

Avatar
planetbrain

29 August 2008 at 9:46am Community Member, 12 Posts

Does anyone know if there is a way to have the blog summary page only display the "show full post" link only if there is more to display than what is already being displayed.

many thanks

Avatar
BLU42 Media

30 August 2008 at 2:21am Community Member, 71 Posts

Hi-

You certainly can! I tried this...

In your BlogEntry.php file:

class BlogEntry extends Page {
   .
   .
   .
   function ShowFullPost() {
      if ($this->Content == $this->ParagraphSummary()) {
         return false;
      } else {
         return true;
      }
   }
}

In your /templates/Includes/BlogSummary.ss file:

   <p class="blogVitals">
      <a href="$Link#PageComments_holder" class="comments" title="View Comments for this post">$Comments.Count comments</a>
      <% if ShowFullPost %> | <a href="$Link" class="readmore" title="Read Full Post">Read the full post</a><% end_if %>
   </p>

Avatar
planetbrain

30 August 2008 at 8:44am Community Member, 12 Posts

Thanks, I'll give that a try.

Avatar
planetbrain

31 August 2008 at 8:36am Community Member, 12 Posts

This doesn't quite seem to work for me!

It always returns true , and displays the link

The ShowFullPost function is definitely being called, as if I reverse the true/false return values then it always returns false.

Any ideas what might be wrong?

Avatar
simon_w

31 August 2008 at 9:26am Forum Moderator, 474 Posts

Try using $this->ParsedContent() instead of $this->Content()

Avatar
planetbrain

31 August 2008 at 9:41am Community Member, 12 Posts

That gives the same result.

Avatar
ajshort

31 August 2008 at 11:16am (Last edited: 31 August 2008 11:16am), Community Member, 244 Posts

I think the problem is in the fact that the FirstParagraph() function in the Text class does all sorts of fancy substrings and stuff like that - so it will return a slightly different result. I think something like this would be a better solution, as it uses the same logic checking as the FirstParagraph() function when checking for new paragraphs:

Note I havent tested it with the blog module, but the algorithim itself should work.

class BlogEntry
{
   
   public function ShowFullPost()
   {
      if(self::$allow_wysiwyg_editing) {
         if(strpos($this->Content, '</p>') === false) return false;
         if(strpos($this->Content, '</p>') == (strlen($this->Content) - 4)) return false;
         else return true;
      } else {
         if(strpos($this->Content, "\n\n") === false) return false;
         if(strpos($this->Content, "\n\n") == (strlen($this->Content) - 2)) return false;
         else return true;
      }
   }
   
}

Edit: fixed up formatting

Avatar
planetbrain

3 September 2008 at 8:41am (Last edited: 3 September 2008 8:43am), Community Member, 12 Posts

Well I struggled to get any of the previous suggestions to work and ended up with the following rough and ready solution.

class BlogEntry extends Page {
.
.
.
function ShowFullPost() {
if ( strlen($this->Content) > ( strlen($this->ParagraphSummary()) -7 ) ) {
return true;
} else {
return false;
}
}

.
.

}

This assumes (probably incorrectly) that the ParagraphSummary is simply the first paragraph wrapped in a <p>....</p> tag, hence the -7

Go to Top