Developer forum

Forum » CMS - Standard features » Filter for Item publisher by query string

Filter for Item publisher by query string

Dan Avramescu
Reply

Hello,

I have a problem with an Item Publisher. I need to filter it by a value taken from query string. This is how I am trying to get the value, but it's not working:

@Code(System.Web.HttpContext.Current.Request.QueryString["category"].ToString().Replace("-"," "))

I can't use @Request because I need the replace. Do you guys have any idea why this is not working?

Thanks,

Dan


Replies

 
Nicolai Høeg Pedersen
Reply

Hi Dan

Can I see a dump of your setup? Where do you add the @Code part?

 
Dan Avramescu
Reply

http://screencast.com/t/pPZGh6BCz7EZ

 
Nicolai Høeg Pedersen
Reply

I am not sure you can use @Code in that field... You could replace the - before adding it to the querystring.

 
Dan Avramescu
Reply

We are using an option from custom urls that replaces spaces with dashes, so DW automatically replaces them to -

 
Dan Avramescu
Reply

If I hardcode the category name there it works. Like this: @Code("name of category")  

 
Nicolai Høeg Pedersen
Reply

What happens if you add System.Web.HttpContext.Current.Request.QueryString["category"].ToString().Replace("-"," ") in a Razor template on that page. What does it return?

I need a link to investigate further.

 
Dan Avramescu
Reply

For http://www.brandfusion.ro/blog/categorie?categorie=BRANDING-ONLINE it shows BRANDING ONLINE so the code is fine. 

The querystring is "categorie" (not category) for the romanian version of the site.

 
Nicolai Høeg Pedersen
Reply

Well, you querystring parameter is called "categorie" and you code says .QueryString["category"] - could that be it...?

 
Dan Avramescu
Reply

No, it's not that. For RO the code is with "categorie"

 
Nicolai Høeg Pedersen
Reply

Well, you cannot use @Code in that field.

You use ?categorie - this parameter is case sensitive so it should be ?Categorie as that is the system name.

This works: http://www.brandfusion.ro/blog/categorie?Categorie=sfa

But filtering does not seem to be very fund of doing filtering on this kind of field (CSV list) with spaces in them.

Please make an upgrade, and we will take a look.

 
Dan Avramescu
Reply

Hi Nicolai,

I've changed the parameter to Categorie, but it still doesn't not work for values with spaces.

 

You must be logged in to post in the forum