Mono Support Is it possible to display "About me" information along with the author image in Blog details page ? 

Viewed 10988 time(s), 8 post(s), 9/5/2012 2:18:54 PM - by super
9/5/2012 2:18:54 PM
6018 Reputation 709 Total posts

Is it possible to display "About me" information along with the author image in Blog details page ?

If yes, Please explain how can i achieve this ?

1
9/5/2012 7:22:43 PM
2218 Reputation 300 Total posts

Hello,

I'm assuming you mean the BlogPostView? The approach which I recommend requires some custom coding.
1. You need to edit the BlogPost.ascx template to add your own custom tag, for example:

<# AboutMe #>
2. In your custom project you need to inherit the BlogPostView control and override its ParseBlogPostTemplateTags method. This is where you should insert your custom logic, you should fetch the UserProfileEntity and add the AboutMe section in the Hashtable, for example:
var tags = base.ParseBlogPostTemplateTags(post, maxTitleChars, maxDescriptionChars, dateFormatString);
tags.Add("<# AboutMe #>", profile.AboutMySelf);
3. Inherit the BlogContainer control and copy the default markup. Change the path of the BlogPostView to point towards your custom control.
4. Inherit Blog.aspx and copy the default markup. Change the path of the BlogContainer to point towards your custom control.
5. Change web.config URL rewriting rules to point towards your custom Blog page.

Regards,
Mario

2
1/14/2013 9:34:47 PM
6018 Reputation 709 Total posts

Mario,

Since I don't have any .cs file (as monox is prebuild) - How am I supposed to do this ?

Also I am not able to understand how to go about it from step 2 onwards - could you please give me detailed steps PLEASE ? what to do and where to do ?

3
1/14/2013 9:55:25 PM
2218 Reputation 300 Total posts

Hello,

The process described here is intended for people without the source code. Can you be more specific as to what exactly is unclear to you?

Regards

4
1/14/2013 11:12:24 PM
6018 Reputation 709 Total posts

2. In your custom project you need to inherit the BlogPostView control and override its ParseBlogPostTemplateTags method. This is where you should insert your custom logic, you should fetch the UserProfileEntity and add the AboutMe section in the Hashtable, for example:
var tags = base.ParseBlogPostTemplateTags(post, maxTitleChars, maxDescriptionChars, dateFormatString);
tags.Add("<# AboutMe #>", profile.AboutMySelf);

Request: I don't have any logic requirement - All I need is that when user clicks any blog post and in the blog post content page, at the bottom of the blog post, it should display "About me" info about the author of the blog post.

I don't know where to add this code ? It can't go in ascx file...this looks like .cs code...
var tags = base.ParseBlogPostTemplateTags(post, maxTitleChars, maxDescriptionChars, dateFormatString);
tags.Add("<# AboutMe #>", profile.AboutMySelf);




3. Inherit the BlogContainer control and copy the default markup. Change the path of the BlogPostView to point towards your custom control.
Request: Could you please show me with an example ? I don't have any custome blogcontainer right now - I am trying to make changed in the original BlogContainer...


4. Inherit Blog.aspx and copy the default markup. Change the path of the BlogContainer to point towards your custom control.
Request: Since I am making changes in the original BlogContainer so I am assuming I don't need to point anything to the custom control...
What default markups you are talking about ?

5. Change web.config URL rewriting rules to point towards your custom Blog page.
Request: Where in web.config - what's the exact location ? where am I looking in config file ?

5
1/15/2013 9:34:11 AM
15993 Reputation 2214 Total posts

Hi Super,

just a tip on the following:

2. In your custom project you need to inherit the BlogPostView control and override its ParseBlogPostTemplateTags method. This is where you should insert your custom logic, you should fetch the UserProfileEntity and add the AboutMe section in the Hashtable, for example:
var tags = base.ParseBlogPostTemplateTags(post, maxTitleChars, maxDescriptionChars, dateFormatString);
tags.Add("<# AboutMe #>", profile.AboutMySelf);
 
Request: I don't have any logic requirement - All I need is that when user clicks any blog post and in the blog post content page, at the bottom of the blog post, it should display "About me" info about the author of the blog post.
 
I don't know where to add this code ? It can't go in ascx file...this looks like .cs code...
var tags = base.ParseBlogPostTemplateTags(post, maxTitleChars, maxDescriptionChars, dateFormatString);
tags.Add("<# AboutMe #>", profile.AboutMySelf);
You can just put the following in your template file: "$Container.DataItem.AspnetUser.UserProfile.AboutMySelf" and use the built in support for NVelocity templating.

In this scenario I think that all this control / markup inheritance in not neccessary, Mario can you please confirm ?

Regards

6
1/15/2013 4:16:53 PM
6018 Reputation 709 Total posts

Khorvat,

You mean in App_Templates/ Default / BlogTemplates / BlogPost.ascx

I should do like this ?

<div class="blog-item xfolkentry">
<div class="avatar">
<a href="<# AuthorProfile #>"><# Avatar #></a>
<a href="<# AuthorLink #>" class="author"><# Author #></a></span>
<div class="arrow"></div>
</div>
<div class="content <# UnpublishedClass #>">
<h2>
<span class="date"><# PubDate #></span>
<# Title #>
</h2>
<p>
<# Categories #>
<# AuthorOtherArticlesLabel #><a href="<# AuthorLink #>"><# Author #></a> <a href="<# AuthorProfile #>"><# AuthorFullName #></a>
</p>
<p><# Content #></p>
<div><# Files #></div>

<div><# $Container.DataItem.AspnetUser.UserProfile.AboutMySelf #></div>

<div class="tags"><# Tags #></div>
<div><# Rating #></div>
<div class="options clearfix">
<span class="float-left">
<# Edit #>
<# Delete #>
<# DeleteUnapproved #>
<# DeleteSpam #>
<# Publish #>
<# Email #>
<# Comments #>
</span>
<span class="float-right"><# TellAFriend #></span>
</div>
</div>
</div>

7
1/17/2013 8:12:39 AM
15993 Reputation 2214 Total posts

No you just need to add it like this:

<div class="blog-item xfolkentry">
<div class="avatar">
<a href="<# AuthorProfile #>"><# Avatar #></a>
<a href="<# AuthorLink #>" class="author"><# Author #></a></span>
<div class="arrow"></div>
</div>
<div class="content <# UnpublishedClass #>">
<h2>
<span class="date"><# PubDate #></span>
<# Title #>
</h2>
<p>
<# Categories #>
<# AuthorOtherArticlesLabel #><a href="<# AuthorLink #>"><# Author #></a> <a href="<# AuthorProfile #>"><# AuthorFullName #></a>
</p>
<p><# Content #></p>
<div><# Files #></div>
 
<div>$Container.DataItem.AspnetUser.UserProfile.AboutMySelf</div>
 
<div class="tags"><# Tags #></div>
<div><# Rating #></div>
<div class="options clearfix">
<span class="float-left">
<# Edit #>
<# Delete #>
<# DeleteUnapproved #>
<# DeleteSpam #>
<# Publish #>
<# Email #>
<# Comments #>
</span>
<span class="float-right"><# TellAFriend #></span>
</div>
</div>
</div>
Without the <# & #>.

Regards

8
This is a demo site for MonoX. Please visit Mono Software for more info.