How to make the home page with images? BE 2

Jul 26, 2011 at 7:16 PM

I want my homepage that consisted of previews of the posts to have an appropriate preview image of that is placed within the post. I am going to place these preview images in a separate directory. How to make it work? So when I publish a post it takes the images to the home page description of the post...

Aug 4, 2011 at 10:15 AM

Bump

I really need an answer please. I think many BE runners will find it usefull too. I'm sure it will become the standart feature for the future versions of BE.

Aug 4, 2011 at 11:48 AM
Edited Oct 24, 2011 at 8:06 PM

Do you have this up yet on a server or have an example of what you are trying to do?

 

If you can take a screen shot with http://awesomescreenshot.com/

 

when you run BE from VS.  

 

Need to see what you are talking about :)

Java Blog

Aug 4, 2011 at 4:16 PM

I have an example

http://www.techfren.com/

There previews come with images.

And here too

http://www.mobiletvworld.com/

http://www.muscletitans.com/default.aspx

 

Aug 4, 2011 at 6:06 PM

I understand now :)

 

Here is an post on how to do it: )

 

http://www.blogenginewall.com/post/2011/03/18/Display-Images-With-Posts-On-BlogEngine-Front-Page.aspx

 

Hope that helps :)

Aug 5, 2011 at 1:31 AM

Thank you, Brian. I have already known this link and it is too overcoded for me and somewhere in this discussion I saw that it works not so well sometimes...

I think it should be a script that may be inserted in the PostView.aspx. Quite simple solution.

I am going to ask the people from examples about how they did it. ))

Aug 5, 2011 at 3:10 AM

 

 

Made these comments on how he used it:
3/24/2011 7:16:33 AM #


For my theme it wasn't necessary to create any extra files, all I did was include the script in the existing PostView.ascx file and then check for post and write the output HTML accordingly.

<% if (HttpContext.Current.Request.RawUrl.Contains("post")) { %>
            <h1><%=Server.HtmlEncode(Post.Title) %></h1>
        <%} else {%>            
            <h1><a href="<%=Post.RelativeLink %>"><%= getImage(true, Post.Content)%><%=Server.HtmlEncode(Post.Title) %></a></h1>                                                                                          
        <%} %>

I also removed the GetShortenedContent(string content, int pos, string link) from the script as this did not apply to me.

Reply

Andy McKay
Andy McKay
3/24/2011 9:36:43 AM #

I was giving this a little more thought. Suppose you want to show the full post in post lists but only descriptions when listed by tag or category, this would be a problem with the current script. To get round this it might be better to alter the script slightly so that you are covered for both scenarios.
The start of the script would then become:

public string getImage(string input)
    {        
        Boolean ShowExcerpt = BlogSettings.Instance.ShowDescriptionInPostList;
        string url = this.Request.RawUrl.ToUpperInvariant();
        if (url.Contains("/CATEGORY/") || url.Contains("?TAG=/"))
        {
            ShowExcerpt = BlogSettings.Instance.ShowDescriptionInPostListForPostsByTagOrCategory;
        }        
            
        if (!ShowExcerpt || input == null) return "";

Then when you call it in your markup, omit the first argument and just pass the post content
<%= getImage(Post.Content)%>

This way you can drop the script in and forget about it, if you make any changes in the BE control panel, the script will handle it automatically.

 

 

Hope this can help :)