Descriptions too short

Topics: Controls
Dec 12, 2008 at 2:33 PM
Hi - I'm using the BlogEngine for my site at http://www.HalfBakedLunatic.com, so far it's very good and easy to use!

One issue I'm having - I use the "Only Show Description of Posts" setting, but it only shows about three lines of the post.  I'd like to show five or six lines - any way to modify the configuration so the "main" page has a little more of the post?


Thanks much,
David Workman (aka "The Half Baked Lunatic")


Oh yeah ... another VERY MINOR issue ... the "remember me next time" checkbox on the Sign In page doesn't seem to do anything. Not a big deal, but wondering if this is a problem with my configuation or if its broken for everybody?
Dec 12, 2008 at 5:35 PM
You can either modify the code that handles that, or you can take advantage o the "break post" extension that is built in. When writing a post just type "[more]" without the quotes at the point where you want the description to end




Dec 13, 2008 at 7:31 PM
Hi Kenpachi - thanks for the help.  I tried using the [more] feature, and it works if I put it BEFORE the point where it was truncating, but not after.  Meaning, I can make the description shorter but not longer.

Can anyone give me a hint as to where in the code I might be able to tweak this?  I'm hoping it's just a text file, and I don't have to re-compile anything?


Thanks,
www.HalfBakedLunatic.com
Coordinator
Dec 13, 2008 at 7:56 PM
What you're looking for appears to be in the PostViewBase.cs file in the Web\Controls folder in the core code.  You'd need to recompile if you change it.  The current code looks like:

...
public string Body
...
if (ShowExcerpt)
...
if (body.Length > 300)
   body = body.Substring(0, 300) + "..." + link;
...

You'd just want to change the number 300 that appears there twice to a larger number.  Currently it shows up to the first 300 characters of each post.

Coordinator
Dec 13, 2008 at 8:01 PM
The other option which Kenpachi described would be to add [more] into your posts, but ALSO uncheck "Only Show Description of Posts".  If you uncheck that option, then you have control over how much of each post to show on the homepage and you wouldn't need to change/recompile the core code.
Dec 13, 2008 at 9:25 PM
I realized just after I left the last message that I needed to uncheck the "only show description of posts" to use the [more] feature.  That actually works better, because it maintains the paragraph spaces in the article (the "description" runs everything together).

Thanks!
www.HalfBakedLunatic.com
Dec 14, 2008 at 5:50 PM
Sorry about that, I forgot that I made my own extension for creating description snippets before discovering the [more] extension. I never removed the code so I don't have to check the "show description box" to make it work

This is what I have in my postbaseview.cs

if (ShowExcerpt)
                {
                    string link = " <a href=\"" + Post.RelativeLink.ToString() + "\">[" + (Page as BlogBasePage).Translate("more") + "]</a>";

                    // Allow for a blog teaser/abstract for longer posts
                    int startIndex = body.IndexOf("[PostTeaser]");

                    if (startIndex != -1)
                    {
                        int endIndex = body.IndexOf("[/PostTeaser]");
                        int length = endIndex - startIndex;
                        body = body.Substring(startIndex, length) + "..." + link;
                    }
                    else
                    {
                        body = Post.Content;
                    }     
                    //if (!string.IsNullOrEmpty(Post.Description))
                    //{
                    //    body = Post.Description + link;
                    //}
                    //else
                    //{   //body = Utils.StripHtml(Post.Content);
                    //    //if (body.Length > 300)
                    //    //    body = body.Substring(0, 300) + "..." + link;
                    //}
                }

                // Remove tags
                body = body.Replace("[PostTeaser]", "");
                body = body.Replace("[/PostTeaser]", "");
Sep 24, 2009 at 10:56 AM

 

I have never tried this before.I will try to use this with my blog.

regards,

Sam - Tax Relief