Portal Engine Questions on portal engine and web parts.
Version 4.x > Portal Engine > Using dropdowns to show archive View modes: 
User avatar
Member
Member
lukeduke - 1/21/2010 10:55:59 AM
   
Using dropdowns to show archive
Hi there,

I'm trying to add dropdowns to filter archived content - what is the best way to do that with Kentico?


Full example - I currently have a great deal of News items under my news section. I'd like to add dropdown boxes at the top of the page with month and year as a way of filtering results, but I'm not sure of the best way. Has anyone tried to do this with any success before?

User avatar
Member
Member
lukeduke - 1/22/2010 5:42:00 AM
   
RE:Using dropdowns to show archive
Hi,

Ok, what I've got so far is a control with 2 dropdowns that add a month and year to the querystring, but I'm still having a job getting the control to interpret that. I'm using a NewsList WebPart and in the Where Condition I have:

Year(PressReleaseDate) = {%Year%}

This is throwing an error. Is the syntax incorrect?

Also, is there a way of bypassing the where condition if the querystring value is empty?

User avatar
Kentico Developer
Kentico Developer
kentico_martind - 2/2/2010 2:28:51 AM
   
RE:Using dropdowns to show archive
Hello,

could you please use following where condition instead:

Year(PressReleaseDate) = '{%year%}'

Please make also sure the PressReleaseDate field exists - the default field for date for news document is called 'NewsReleaseDate'.

Best Regards,

Martin

User avatar
Member
Member
lukeduke - 2/2/2010 4:46:29 AM
   
RE:Using dropdowns to show archive
Thanks.

I actually got it going eventually but forgot to post my solution.

In the end my where condition was:

Year(PressReleaseDate) LIKE '{%year|(default)%%%}' AND Month(PressReleaseDate) LIKE '{%month|(default)%%%}'

It was having the default vaue of %% which stopped the error.

User avatar
Kentico Developer
Kentico Developer
kentico_martind - 2/4/2010 7:20:48 AM
   
RE:Using dropdowns to show archive
Hello,

Ok, thank you for letting us know your solution.

Have a nice day,

Martin Dobsicek

User avatar
Member
Member
ctaleck IPAGlobal - 2/16/2010 9:53:47 AM
   
RE:Using dropdowns to show archive
To make this post complete, do you mind showing how you made the drop-down boxes to populate the querystring?

Is this a WebPart or custom code?

User avatar
Kentico Developer
Kentico Developer
kentico_helenag - 2/17/2010 5:44:28 AM
   
RE:Using dropdowns to show archive
Hello,

I suppose it is a custom web part.

You may add a button to the custom web part and add the query strings on OnClick action like this:

string url = UrlHelper.RawUrl;

url = UrlHelper.RemoveParameterFromUrl(url, "querystring");

if (yourdropdownlist.SelectedValue != "")
{
url = UrlHelper.AddParameterToUrl(url, "querystring", yourdropdownlist.SelectedValue);
}

// Redirect with new query parameters
UrlHelper.Redirect(url);


The API Reference is here: API Reference
How to create a custom web parts: Developing web parts


Best regards,
Helena Grulichova