ASPX templates
Version 6.x > ASPX templates > how to create related news function using Repeater? View modes: 
User avatar
Member
Member
duongvannam - 12/10/2011 1:00:41 AM
   
how to create related news function using Repeater?
I'm using repeater.
1.I want to create a related news function to display 10 newest news except current news.

i wrote:

this.cmsrepeaterrelatednews.WhereCondition = string.Format("NodeAliasPath <>'{0}'", Functions.GetAliasPath());
this.cmsrepeaterrelatednews.ReloadData(true);


But it's show current news.

2.I want to create a related news function to display 10 newest news except current news.
The 10 related news have title like current title display.
how can i do?
Thank you


User avatar
Kentico Developer
Kentico Developer
kentico_ivanat - 12/12/2011 9:04:36 AM
   
RE:how to create related news function using Repeater?
Hi,

you can change the condition a little.

According to your description it seems that you are on the current news document. It means that all its information are available in the context.

Therefore you can get the ID of current news:
int currentNewsID = ValidationHelper.GetInteger(CMS.CMSHelper.CMSContext.CurrentDocument.GetValue("NewsID"),0);

Then you can change condition to NewsID<>currentNewsID

Then in the repeater you should define Transformation which is used to display news documents.

Inside the transformation you can call the method <%# Eval("ColumnName")%> so the items from repeater's data set will be displayed.

Best regards,
Ivana Tomanickova

User avatar
Member
Member
tpAbramsHaldis-hotmail - 12/20/2011 3:31:16 AM
   
RE:how to create related news function using Repeater?
Oh! That all we have to do create related news?
Great! Thought it will take much more efforts and time ti fix that one!
Thank you so much for your help! You're the best!
____