Portal Engine Questions on portal engine and web parts.
Version 5.x > Portal Engine > RSS For All Blogs Across Site View modes: 
User avatar
Member
Member
kelements - 6/9/2011 11:42:10 PM
   
RSS For All Blogs Across Site
I have been trying to set up an RSS webpart for all blogs across my entire site. I am trying to place it in my website layout. When clicked, the user subscribes to a feed of all blog post across my entire site. Can someone lead me in the right direction on how to achieve this?

Thanks!

User avatar
Kentico Developer
Kentico Developer
kentico_ondrejv - 6/10/2011 1:26:14 AM
   
RE:RSS For All Blogs Across Site
Hello,

You can use e.g. the Blog posts RSS feed web part for this aim. Actually, it has the Path property which can be set to appropriate location in your site, for instance to /%, which displays all the blog post items all across the site.

For more details I would recommend you to install our Corporate Site sample site where you can see it in action on the Blogs document.

Best regards
Ondrej Vasil

User avatar
Member
Member
kelements - 6/11/2011 11:54:44 AM
   
RE:RSS For All Blogs Across Site
Thanks Ondrej, I think I tried every RSS except that one.

I am experiencing one problem, on my home page, which does not include a blog repeater, this RSS feed does list all blog posts when clicked. When I go to a page other than Home the RSS url changes undesirably (but still lists all posts in the feed from entire site).

Here's an example of how the rss link looks:

On the home page (no blog repeater) = "Home?rss=blogs"
On my food blog page= "Food?rss=blogs"
On my food blog post page= "Food/May-2011/Beefy-Bits?rss=blogs"

The three above show all blog posts across the site when clicked, however, why are each different in terms of the URL? I would like the link to always read, "Home?rss=blogs" no matter what page the user is on.

Thanks for your help.

User avatar
Member
Member
kentico_michal - 6/12/2011 12:23:11 AM
   
RE:RSS For All Blogs Across Site
Hello,

This behavior is by design since the RSS link always points to the current document. If you want to change this behavior, you will need to modify the code of this web part (~\CMSWebParts\Syndication\Documents\CMSRSSFeed.ascx.cs). Currently, the feed link is created using the current document:

rssFeed.FeedLink = UrlHelper.GetAbsoluteUrl(UrlHelper.AddParameterToUrl(UrlHelper.CurrentURL, QueryStringKey, FeedName));

You can add a new property to the web part of type Document selector. This property gives user ability to specify which document will be used in the RSS feed link. This form control stores NodeGUID:

    
public System.Guid NodeGUID
{
get
{
return ValidationHelper.GetGuid(GetValue("NodeGUID"), System.Guid.Empty);
}
set
{
SetValue("NodeGUID", value);
}
}



Than, you can replace above line of code with the following code:
           
CMS.TreeEngine.TreeNode node = null;
UserInfo ui = UserInfoProvider.GetUserInfo("administrator");
CMS.TreeEngine.TreeProvider tree = new CMS.TreeEngine.TreeProvider(ui);
node = tree.SelectSingleNode(NodeGUID, CMS.CMSHelper.CMSContext.CurrentDocumentCulture.CultureCode, CMS.CMSHelper.CMSContext.CurrentSiteName);

if (node != null)
{
string url = CMS.CMSHelper.CMSContext.GetUrl(node.NodeAliasPath, null, node.NodeSiteName);
rssFeed.FeedLink = CMS.GlobalHelper.UrlHelper.GetAbsoluteUrl(UrlHelper.AddParameterToUrl(url , QueryStringKey, FeedName));
}


Please do no forget to create a copy of the web part: Modifying the code of webparts

Best regards,
Michal Legen

User avatar
Member
Member
kelements - 6/13/2011 5:02:24 PM
   
RE:RSS For All Blogs Across Site
kentico_michal wrote:
You can add a new property to the web part of type Document selector. This property gives user ability to specify which document will be used in the RSS feed link. This form control stores NodeGUID:

    
public System.Guid NodeGUID
{
get
{
return ValidationHelper.GetGuid(GetValue("NodeGUID"), System.Guid.Empty);
}
set
{
SetValue("NodeGUID", value);
}
}



Than, you can replace above line of code with the following code:
           
CMS.TreeEngine.TreeNode node = null;
UserInfo ui = UserInfoProvider.GetUserInfo("administrator");
CMS.TreeEngine.TreeProvider tree = new CMS.TreeEngine.TreeProvider(ui);
node = tree.SelectSingleNode(NodeGUID, CMS.CMSHelper.CMSContext.CurrentDocumentCulture.CultureCode, CMS.CMSHelper.CMSContext.CurrentSiteName);

if (node != null)
{
string url = CMS.CMSHelper.CMSContext.GetUrl(node.NodeAliasPath, null, node.NodeSiteName);
rssFeed.FeedLink = CMS.GlobalHelper.UrlHelper.GetAbsoluteUrl(UrlHelper.AddParameterToUrl(url , QueryStringKey, FeedName));
}



Hi Michal, I am unclear where the above code goes. Can you please help further? Thanks!

KEN

User avatar
Member
Member
kentico_michal - 6/14/2011 1:46:41 AM
   
RE:RSS For All Blogs Across Site
Hi Ken,

I will try to explain it in more detail.
The code I posted here should ensure that the Blog post RSS feed web part will produce one unified link. So, in your case it would produce the link "Home?rss=blogs", independent of a document the web part is placed on.

In order for this to work, you need to add a new property to the web part and as I wrote in the previous comment, this way an editor will be able to specify the document which will be used in the returned link (in this case Home).

So please open the following file ~\CMSWebParts\Syndication\Documents\CMSRSSFeed.ascx.cs (or the code of the copied web part) and add this code that defines the new property:


public System.Guid NodeGUID
{
get
{
return ValidationHelper.GetGuid(GetValue("NodeGUID"), System.Guid.Empty);
}
set
{
SetValue("NodeGUID", value);
}
}


In order to see this property in the list of Blog post RSS feed web part properties you need to specify a new property also in the Site manager -> Development -> Web parts -> edit the Blog post RSS feed web part or its copy -> Properties -> define a new property:

Attribute name: Document
Attribute type: Text
Attribute size: 100
Display attribute in the editing form: true
Field caption: Document
Field type: Document selector


By default, the RSS link is generated in the SetupControl() (~\CMSWebParts\Syndication\Documents\CMSRSSFeed.ascx.cs or the code of the copied web part) method:

rssFeed.FeedLink = UrlHelper.GetAbsoluteUrl(UrlHelper.AddParameterToUrl(UrlHelper.CurrentURL, QueryStringKey, FeedName));

So, you will need to replace it with the following code:


CMS.TreeEngine.TreeNode node = null;
UserInfo ui = UserInfoProvider.GetUserInfo("administrator");
CMS.TreeEngine.TreeProvider tree = new CMS.TreeEngine.TreeProvider(ui);
node = tree.SelectSingleNode(NodeGUID, CMS.CMSHelper.CMSContext.CurrentDocumentCulture.CultureCode, CMS.CMSHelper.CMSContext.CurrentSiteName);

if (node != null)
{
string url = CMS.CMSHelper.CMSContext.GetUrl(node.NodeAliasPath, null, node.NodeSiteName);
rssFeed.FeedLink = CMS.GlobalHelper.UrlHelper.GetAbsoluteUrl(UrlHelper.AddParameterToUrl(url , QueryStringKey, FeedName));
}


I hope it makes sense.

Best regards,
Michal Legen