ASPX templates
Version 7.x > ASPX templates > Querystring parameters with CMSRepeater and UniPager View modes: 
User avatar
Member
Member
chris.foot-64digital.co - 4/12/2013 10:48:35 AM
   
Querystring parameters with CMSRepeater and UniPager
I'm very new to Kentico so please forgive me if this is an obvious question.

I'm currently building a news section with an archive on a site I'm developing. I have created the news page using a CMSRepeater and UniPager and I want to display a news archive similar to the blog archive. To do this I have used a QueryRepeater and I've got it working successfully however, I can't work out how to make the CMSRepeater show the month from the querystring. Is there an easy way to do this and still have the UniPager work?

Thanks

Chris

User avatar
Member
Member
kentico_sandroj - 4/12/2013 9:52:42 PM
   
RE:Querystring parameters with CMSRepeater and UniPager
Hi Chris,

No worries about being new to Kentico - we all have to start somewhere :)

So where in the repeater would you like to show the querystring? A screen shot of your setup and expected outcome would likely help. However, this may give you the answer you are looking for: QueryString Macro

If I misunderstood the question, please let me know and I'll find another solution for you.

Regards,
Sandro

User avatar
Member
Member
chris.foot-64digital.co - 4/15/2013 4:00:59 AM
   
RE:Querystring parameters with CMSRepeater and UniPager
Hi Sandro,

The query string is generated by a different repeater. The problem i'm having is getting the repeater which shows the articles to filter based on the query string (so month=012013 should show articles from January 2013 for instance). However, it needs to be able to page based on the query string as well since this is the way that the unipager works.

Thanks

Chris

User avatar
Member
Member
kentico_sandroj - 4/15/2013 5:10:35 PM
   
RE:Querystring parameters with CMSRepeater and UniPager
Hi Chris,

I am not sure how you have this configured, but you should be able to use the querystring macro in the WHERE statement for your data source in order to filter. If this doesn't make sense or if I misunderstood, please send me a screen short or a detailed explanation of how you have configured these Web parts and I'll re-create what you have in order to test. Please make sure to specify all the relevant settings.

Thanks!
-Sandro

User avatar
Member
Member
chris.foot-64digital.co - 4/16/2013 3:17:13 AM
   
RE:Querystring parameters with CMSRepeater and UniPager
I don't have a where clause at the moment, i'm using classnames to fetch the articles. This repeater handles both the list of articles and the actual article pages themselves. It looks a bit like this:

 
<cms:CMSRepeater id="newsList" runat="server" ClassNames="cms.news" TransformationName="cms.news.newslist" selectedItemTransformationName="cms.news.default" DelayedLoading="true" >
<HeaderTemplate>
<div class="articles">
</HeaderTemplate>
<FooterTemplate>
</div>
</FooterTemplate>
</cms:CMSRepeater>


I have a unipager on the page linked to this repeater:


<cms:UniPager ID="UniPager1" runat="server" PageControl="newsList" HidePagerForSinglePage="true" PagerMode="Querystring" PageSize="1">
<PageNumbersTemplate><a href="<%# Eval("PageURL") %>" class="btn paging-number"><%# Eval("Page") %></a></PageNumbersTemplate>
<PreviousPageTemplate><a href="<%# Eval("PreviousUrl") %>" class="btn paging-previous"><i class="icon-left"></i></a></PreviousPageTemplate>
<NextPageTemplate><a href="<%# Eval("NextUrl") %>" class="btn paging-previous"><i class="icon-right"></i></a></NextPageTemplate>
<LayoutTemplate>
<div class="box-titleBar">
<div class="paging">
<asp:PlaceHolder runat="server" ID="plcPreviousPage"></asp:PlaceHolder>
<asp:PlaceHolder runat="server" ID="plcPageNumbers"></asp:PlaceHolder>
<asp:PlaceHolder runat="server" ID="plcNextPage"></asp:PlaceHolder>
</div>
<h3>News</h3>
</div>
</LayoutTemplate>
</cms:UniPager>


And I have a queryrepeater that generates links with the archive month that looks like this:

<cms:QueryRepeater ID="QueryRepeater1" runat="server" QueryName="cms.news.months" TransformationName="cms.news.months" ></cms:QueryRepeater>


Thanks

Chris

User avatar
Member
Member
chris.foot-64digital.co - 4/19/2013 8:14:15 AM
   
RE:Querystring parameters with CMSRepeater and UniPager
In case anyone is interested (or has a better solution!) I have achieved this using codebehind as follows:


if (Request.QueryString["month"] != null)
{
// Set repeater where clause
DateTime archiveMonth = DateTime.Now;
if (DateTime.TryParse("01/" + Request.QueryString["month"], out archiveMonth))
{
newsList.WhereCondition = "NewsReleaseDate > '" + archiveMonth.ToString("dd MMMM yyyy") + "' AND NewsReleaseDate < '" + archiveMonth.AddMonths(1).AddDays(-1).ToString("dd MMMM yyyy") + "'";
}
}



Chris

User avatar
Member
Member
kentico_sandroj - 4/23/2013 5:56:04 PM
   
RE:Querystring parameters with CMSRepeater and UniPager
Hi Chris,

Thank you for sharing this solution! I will investigate to see if there are any other (better) options but this seems to be functional - I will keep you updated.

Thanks again,
Sandro