I have various pages on a site that need to show news / events/ blog posts etc. that are related to that section / page of the site.
I've set up various categories and for the purposes of testing I've created a few test news / blog items that are assigned to the same categories. In my aspx page template I need to alter my news repeater to display the various items associated with these categories. The test repeater I have looks like this:
<cms:CMSRepeaterWithEffect ID="CMSRepeater2" runat="server" Path="/%" ClassNames="cms.news" TransformationName="cms.news.preview" EnablePaging="true" TopN="5" SelectedItemTransformationName="cms.news.default" ItemSeparator="
I'll also need to do this with blog posts etc, what's the best way of achieving this?
Hi,
add to your repeater WHERE condition: WhereCondition="CategoryID = 1"
You can load it from code:
If you are thinking about path as category /News /Events, then just change Path in repeater: Path="/News/%"
Hope this helps
Sorry core example:
<script runat="server"> protected override void OnInit(EventArgs e) { base.OnInit(e); var sqlFormattedDate = myDateTime.Date.ToString("yyyy-MM-dd HH:mm:ss"); NewsRpt.WhereCondition= "CategoryID = 1"; NewsRpt.ReloadData(true); } </script>
Thanks for the replies. So I add a news repeater on the aspx page and then in the code behind I can pass in a wherecondition variable?
Do you know where I could find examples of the generic news repeater or is the repeater I'm using ok for that purpose?
This isn't working for me as it's saying that CategoryID is an invalid column name. The news doc type doesn't have categoryID in there but I had assigned the news item to a category, not sure how to query against that relationship though.
Are you using .ASPX or Portal mode? There isn't a CategoryID on the Document, because its a many to many relationship. You have to do something like this to get the categories a document is assigned to.
Hi, sorry... CategoryID can be get from CMS_Document... Brendan is right.
Please, sign in to be able to submit a new answer.