The content you're reading is getting on in years
This post is on the older side and its content may be out of date.
Be sure to visit our blogs homepage for our latest news, updates and information.
When filtering content items in Sitefinity CMS using both categories/tags widget and archive by query, a string gets appended to the previous query string. This blog post explores how you can remove it.
By default archive and categories/tags widgets work with UrlPath which is by default configured on each widget against with filtering can be performed:
site.com/page/year=2013/month=04/day=02
The problem doesn`t appear when filtering using UrlPath.
When UrlPath is changed to QueryString by editing a widget, go to advanced properties->UrlEvaluationMode and set it form UrlPaht to QueryString. Here is a screenshot.
The widgets will provide the filtering functionality by appending a query string to the current page URL.
The problem comes when both archive and categories/tags widget perform filtering together.
First, filter with the archive widget and the URL gets filtered by date:
site.com/page?year=2013&month=04&day=02&taxonomy=categories&propertyName=category&taxon=%2fproducts
This appending is used to filter based on the criteria on both the archive and the taxonomy control tough in some cases this is not needed. To overcome this, create custom archive and categories widgets that remove the already existing query string when filtering.
Attached is the source of those controls.
The logic that clears the query string is located in CustomDateEvaluator.cs for the archive control and in CustomTaxonEvaluator.cs for categories control.
case
UrlEvaluationMode.QueryString:
var yearFullUrlKey = String.Concat(urlKeyPrefix,
"year"
);
var monthFullUrlKey = String.Concat(urlKeyPrefix,
"month"
);
var dayFullUrlKey = String.Concat(urlKeyPrefix,
"day"
);
var qString = QueryStringBuilder.Current.Reset();
To install the new widgets add the attached classes in your Sitefinity project and compile it.
Go to Administration->Settings->Advanced->Toolboxes->Toolboxes->PageControls->Sections->NavigationToolboxsection->Tools create new and in the textbox fill in the class for the new archive control.
In the case with the namespace for the classes attached:
Control CLR Type or Virtual Path: SitefinityWebApp.CustomArchive
Controller CLR type:CustomArchive
Name:CustomArchive
Title: New Archive Control
Save changes and the new archive control is ready for use.
For categories control go to Administration->Settings->Advanced->Toolboxes->Toolboxes->PageControls->Sections->NavigationToolboxsection->Tools create new and in the textbox fill in the class for the new archive control.
In the case with the namespace for the classes attached:
Control CLR Type or Virtual Path: SitefinityWebApp. CustomTaxonomyControl
Controller CLR type: CustomTaxonomyControl
Name: CustomTaxonomyControl
Title: New Categories Control
Save changes and the new categories/tags control is ready for use.
View all posts from The Progress Team on the Progress blog. Connect with us about all things application development and deployment, data integration and digital business.
Let our experts teach you how to use Sitefinity's best-in-class features to deliver compelling digital experiences.
Learn MoreSubscribe to get all the news, info and tutorials you need to build better business apps and sites
Progress collects the Personal Information set out in our Privacy Policy and the Supplemental Privacy notice for residents of California and other US States and uses it for the purposes stated in that policy.
You can also ask us not to share your Personal Information to third parties here: Do Not Sell or Share My Info
We see that you have already chosen to receive marketing materials from us. If you wish to change this at any time you may do so by clicking here.
Thank you for your continued interest in Progress. Based on either your previous activity on our websites or our ongoing relationship, we will keep you updated on our products, solutions, services, company news and events. If you decide that you want to be removed from our mailing lists at any time, you can change your contact preferences by clicking here.