Mono Support How to get ALL BLOG POSTS on the homepage ? 

Viewed 13284 time(s), 7 post(s), 7/18/2012 11:31:58 AM - by super
7/18/2012 11:31:59 AM
6018 Reputation 709 Total posts

How to get ALL BLOG POSTS on the homepage ? I would like to display content of Blog.aspx page on the homepage, how to do that ?

1
7/18/2012 1:15:20 PM
15993 Reputation 2214 Total posts

Hi,

you will need to instantiate BlogContainer module on your home page e.g.

<%@ Register Assembly="MonoX" Namespace="MonoSoftware.MonoX" TagPrefix="portal" %>
<%@ Register TagPrefix="MonoX" TagName="BlogContainer" Src="/MonoX/ModuleGallery/Blog/BlogContainer.ascx" %>
 
<portal:PortalWebPartZoneTableless HeaderText='<%$ Code: PageResources.Zone_LeftPartZone %>' ID="leftPartZone" runat="server" Width="100%" ChromeTemplateFile="LeftColumn.htm">
      <ZoneTemplate>
          <MonoX:BlogContainer ID="blogContainer" runat="server" UsePrettyPhoto="true" DateFormatString="d"
          RelatedContentVisible="false" EnableSyntaxHighlighter="true" GravatarRenderType="NotSet" />
      </ZoneTemplate>
  </portal:PortalWebPartZoneTableless>
Note: Put the module in the PortalWebPartZoneTableless only if you want to dynamically administer the module, if not please us this

<MonoX:BlogContainer ID="blogContainer" runat="server" UsePrettyPhoto="true" DateFormatString="d"
          RelatedContentVisible="false" EnableSyntaxHighlighter="true" GravatarRenderType="NotSet" />

Also note that BlogContainer will use the BlogSlug from the url if any, if not you need to manually set the BlogSlug if you want to bound the module to specific blog.


Regards

2
7/18/2012 1:16:30 PM
15993 Reputation 2214 Total posts

One more thing you need to change the URL rewriting if you want fancy URLs, you can find them in the web.config

<!-- dynamic blog post rules, can be used regardless of the actual name of the page that holds blog parts -->
<rewrite url="^(.*)/(.*)/post/(.*)/(.*)/(.*)/BlogCommentsPageNo/(.*)/BlogFilesPageNo/(.*)/(\?(.+))?$" to="$1/$2.aspx?BlogSlug=$3&BlogPostId=$4&BlogCommentsPageNo=$6&BlogFilesPageNo=$7&$9" name="BlogPostCommentsFiles" defaultPage="/Blog.aspx" urlPattern="/{PageName}/post/{Blog.Slug}/{IdentityId}/{Slug}/" />
<rewrite url="^(.*)/(.*)/post/(.*)/(.*)/(.*)/BlogFilesPageNo/(.*)/BlogCommentsPageNo/(.*)/(\?(.+))?$" to="$1/$2.aspx?BlogSlug=$3&BlogPostId=$4&BlogFilesPageNo=$6&BlogCommentsPageNo=$7&$9" name="BlogPostFilesComments" defaultPage="/Blog.aspx" urlPattern="/{PageName}/post/{Blog.Slug}/{IdentityId}/{Slug}/" />
<rewrite url="^(.*)/(.*)/post/(.*)/(.*)/(.*)/BlogFilesPageNo/(.*)/(\?(.+))?$" to="$1/$2.aspx?BlogSlug=$3&BlogPostId=$4&BlogFilesPageNo=$6&$8" name="BlogPostFiles" defaultPage="/Blog.aspx" urlPattern="/{PageName}/post/{Blog.Slug}/{IdentityId}/{Slug}/" />
<rewrite url="^(.*)/(.*)/post/(.*)/(.*)/(.*)/BlogCommentsPageNo/(.*)/(\?(.+))?$" to="$1/$2.aspx?BlogSlug=$3&BlogPostId=$4&BlogCommentsPageNo=$6&$8" name="BlogPostComments" defaultPage="/Blog.aspx" urlPattern="/{PageName}/post/{Blog.Slug}/{IdentityId}/{Slug}/" />
<rewrite url="^(.*)/(.*)/post/(.*)/(.*)/(.*)/(\?(.+))?$" to="$1/$2.aspx?BlogSlug=$3&BlogPostId=$4&$7" name="BlogPost" defaultPage="/Blog.aspx" urlPattern="/{PageName}/post/{Blog.Slug}/{IdentityId}/{Slug}/" />
<rewrite url="^(.*)/(.*)/posts/(.*)/BlogPostPage/(.*)/(\?(.+))?$" to="$1/$2.aspx?BlogSlug=$3&BlogPostPage=$4&$6" name="BlogPostsPaged" defaultPage="/Blog.aspx" urlPattern="/{PageName}/posts/{Slug}/BlogPostPage/{PageNo}/" />
<rewrite url="^(.*)/(.*)/posts/(.*)/(\?(.+))?$" to="$1/$2.aspx?BlogSlug=$3&$5" name="BlogPosts" defaultPage="/Blog.aspx" urlPattern="/{PageName}/posts/{Slug}/" />
<rewrite url="^(.*)/(.*)/search/(.*)/(.*)/(.*)/(\?(.+))?$" to="$1/$2.aspx?BlogSlug=$3&SearchAction=$4&SearchValue=$5&$7" name="BlogSearch" defaultPage="/Blog.aspx" urlPattern="/{PageName}/search/{Slug}/{SearchAction}/{SearchValue}/" />
<rewrite url="^(.*)/(.*)/blog-tag/(.*)/(.*)/(\?(.+))?$" to="$1/$2.aspx?BlogSlug=$3&SearchAction=tag&SearchValue=$4&$6" name="BlogTag" defaultPage="/Blog.aspx" urlPattern="/{PageName}/blog-tag/{Slug}/{Tag}/" />
<rewrite url="^(.*)/(.*)/settings/(.*)/(\?(.+))?$" to="$1/$2.aspx?ShowBlogSettings=true&BlogSlug=$3&$5" name="BlogSettings" defaultPage="/Blog.aspx" urlPattern="/{PageName}/settings/{Slug}/" />
<rewrite url="^(.*)/(.*)/comments/(.*)/BlogCommentsPageNo/(.*)/(\?(.+))?$" to="$1/$2.aspx?ShowBlogCommentsAdmin=true&BlogSlug=$3&BlogCommentsPageNo=$4&$6" name="BlogCommentsAdminComments" defaultPage="/Blog.aspx" urlPattern="/{PageName}/comments/{Slug}/" />
<rewrite url="^(.*)/(.*)/comments/(.*)/(\?(.+))?$" to="$1/$2.aspx?ShowBlogCommentsAdmin=true&BlogSlug=$3&$5" name="BlogCommentsAdmin" defaultPage="/Blog.aspx" urlPattern="/{PageName}/comments/{Slug}/" />
<rewrite url="^(.*)/(.*)/edit/(.*)/(.*)/(.*)/(\?(.+))?$" to="$1/$2.aspx?BlogSlug=$3&BlogPostId=$4&BlogEditMode=true&$7" name="BlogPostEdit" defaultPage="/Blog.aspx" urlPattern="/{PageName}/edit/{Blog.Slug}/{IdentityId}/{Slug}/" />
<rewrite url="^(.*)/(.*)/insert/(.*)/(\?(.+))?$" to="$1/$2.aspx?BlogSlug=$3&BlogInsertMode=true&$5" name="BlogPostInsert" defaultPage="/Blog.aspx" urlPattern="/{PageName}/insert/{Slug}/" />
<!-- shows all blog posts regardless of the blog they were posted to -->
<rewrite url="^(.*)/(.*)/posts/(\?(.+))?$" to="$1/$2.aspx$3" name="AllBlogPosts" defaultPage="/Blog.aspx" urlPattern="/{PageName}/posts/{Slug}/" />
<rewrite url="^(.*)/(.*)/posts/(.*)/wlwmanifest.xml(\?(.+))?$" to="$1/wlwmanifest.xml" name="WlwManifest" urlPattern="/wlwmanifest.xml" />


Regards

3
7/18/2012 4:36:41 PM
6018 Reputation 709 Total posts

Thank you khorvat - I will try the code and I just found out that I can also move / add modules dynamically by drag n drop on the homepage which is a great feature. If I add all blog module on the homepage side column, i won't have to touch the code - great feature.

4
7/19/2012 6:45:38 AM
15993 Reputation 2214 Total posts

Yep, you can instantiate everything dynamically via WebPart and Zones so every module can be dropped to the Zone, I just thought that you want to get  your hands dirty and do some programming :)

Regards

5
7/19/2012 10:45:28 AM
6018 Reputation 709 Total posts

Lol...I will do that in required.

Quick question: Once I re-arrange or add / delete modules via webpart and zones and in future if I upgrade the monoX to the next higher version - will this zone arrange will remain same (means will be saved in database) or i will have to re-arrange everything from starting once again after every upgrade of monoX ?

6
7/19/2012 3:34:41 PM
15993 Reputation 2214 Total posts

It will be saved in the database so your modules and module settings are safe.

Regards

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