Default value for url with multiple wildcards

Justin L asked on May 23, 2017 12:08

Hello Kentico guru's,

I am trying to build a F.A.Q in which questions are organized in (dynamic) categories and subcategories, and i've organized it like this:

Image Text

And i'm using the following pages to display the content, with these url's / aliases / wildcards:

FAQ: /faq (shows overview of categories and subcategories)

Detail: /faq/{category}/{subcategory} (Shows a list of the subcategories and the questions using repeaters)

Now i would like to set it up so that the subcategory is optional and the F.A.Q outputs the questions from the first subcategory if there is no subcategory present in the URL. Through the documentation i have found out you can set defaults for wildcard URL's, but i am not able to get it working.

When i try to set a default like this /faq/{category}/{subcategory;SubcategoryA} and i try to visit /faq/Category1 i run in to an 404 error page. Am i missing something, or is the syntax not correct?

Please help!

Best regards, Justin

Correct Answer

Brenden Kehren answered on May 23, 2017 14:15

I'm not positive you need any alias, especially since you already have the structure build out in the content tree AND if the user can navigate to the category and/or subcategory. Just update your page template(s). Also unless you plan to have or display your "Overview" folder, there is no need for it, just makes things more complicated.

You can simply set your URL dynamically with a macro depending on the node level like so:

/{0}/% = /faq/%
/{0}/{1}/% = /faq/category/%
/{0}/{1}/{2}% = /faq/category/subcategory%

Macro would look like (assuming no "Overview" folder):

{% if (CurrentDocument.NodeLevel == 1) { "/{0}/{1}/%" } else { if (CurrentDocument.NodeLevel == 2) { "/{0}/{1}/{2}/%" } else { "/{0}/%" } } |(identity)GlobalAdministrator%}

Maybe I'm wrong but I think you're over complicating it since you already have the structure there. You could even go one step further and not use the macro and simply have a specific page template for the FAQ page, one for the Category and one for the Subcategory since they are all different page types. Then in your page type just assign a default page template and the user never has to determine which one to use AND you can set the values like I showed above in the path property.

1 votesVote for this answer Unmark Correct answer

Recent Answers

Prashant Verma answered on May 23, 2017 12:23 (last edited on May 23, 2017 12:38)

Hi Justin

You simple need to make wildcard URL for both the case's

if subcategory available your wild card URL,






Happy to help you

2 votesVote for this answer Mark as a Correct answer

Justin L answered on May 23, 2017 13:10 (last edited on May 23, 2017 13:11)

Hi Prashant, thank you for your response.

Unfortunately this doesn't work just yet, if i add the alias without the subcategory like you mentioned, it throws a 404 error when visiting the detailpage through /faq/Category1/SubcategoryA. The /faq/Category1 now seems to work, but still does not render with a default, even when i use these aliases:



What am i doing wrong / missing?

0 votesVote for this answer Mark as a Correct answer

Prashant Verma answered on May 23, 2017 14:14 (last edited on May 23, 2017 14:17)

Hi Justin,

Can you please share the wildcard URLs snapshot.So I can check what's missing.

But as you said you are using this page alaises


It seems your Url pattern is not correct.Please check documentation for url patterns. It should be like this /faq/{category}/{subcategory}

0 votesVote for this answer Mark as a Correct answer

Justin L answered on May 23, 2017 15:12 (last edited on May 23, 2017 15:21)

@Prashant, the url pattern i previously posted, included the default value which is mentioned at:

Here is a screenshot of my current situation: Image Text

@Brenden, you might be right that it looks a little complicated. But essentially there is only a single FAQ/Overview page and a Detail page, the purpose of the overview is to guide the user to a subcategory (in the user interface, a user is able two switch categories via javascript and select a subcategory). When a user selects a subcategory, he reaches the detail page which shows the questions from the selected subcategory, and in a sidemenu he/she is able to switch categories/subcategories. So there is no real subcategory page, as this should be the Detail page with a default 'subcategory' fallback, i hope you guys understand.

The way i interpreted the documentation (Wildcard URLs documentation section: Default wildcard values) you should be able to set defaults/fallbacks for when there is no wildcard value, so when a user visits /faq/Category1/SubcategoryA and switches to /faq/Category2/, i want it to load /faq/Category2/{first default subcategory}. But i'm unable to get default value working...

0 votesVote for this answer Mark as a Correct answer

Prashant Verma answered on May 23, 2017 15:34 (last edited on May 23, 2017 15:35)

Hey Justin,

For first default subcategory You need to do some other settings.

Step 1: Go to your subcategory parent page in document tree then select navigation from properties tab.

Step 2: Then you need to set the option called redirect to first child.

Conclusion : After apply those setting whenever user go to specific subcategory parent then by default it redirect to first value.

Do same setting for other subcategory.


0 votesVote for this answer Mark as a Correct answer

Roman Hutnyk answered on May 23, 2017 16:17

I agree with Brenden: drop your details page and implement appropriate template for category and subcategory pages, so they are details page for itself.

0 votesVote for this answer Mark as a Correct answer

Justin L answered on May 24, 2017 12:04 (last edited on May 24, 2017 13:20)

Thanks a lot guys, i've ditched the setup with the detail page and i now have it working with the macros. Makes much more sense this way. Here is a screenshot:

Image Text

The only thing i'm still missing is the default, for when a category is visited without a subcategory... i tried to set the "Redirect to first child (/FAQ/Category1/SubcategoryA.aspx)" on the Category page, but i still get an 404 when i try to visit /Faq/Category1. Do i need to do anything else for this in order for it to work?

0 votesVote for this answer Mark as a Correct answer

Justin L answered on May 31, 2017 15:00 (last edited on May 31, 2017 15:01)

Hello Kentico dev's, can someone please help me with the default mentioned in my previous post?

I've created page-templates for the FAQ-level and Subcategory-level. On the FAQ-level a user can select a category and then a subcategory via a javascript interface. When a user selects a subcategory he/she will be linked to the Subcategory-pagetemplate where he/she can see all the questions from this subcategory.

Because the category-level does not have a real page, i want to redirect users directly to the subcategory-pagetemplate. And i've tried setting up a redir in the Navigation tab. But it does not seem to work, because i can still visit /FAQ/Category1 and it shows a broken version of the template it inherits from the FAQ level, instead of redirecting me to a subcategory.

Image Text

How do i make this redirect work?

Please help!

Best regards, Justin

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.