5

On our website we have a page which is accessible via a path like:

www.example.com/statistics

We would like this page to show different content based on the URI, e.g.

www.example.com/statistics/january

www.example.com/statistics/february

How can I implement this? If the parameters were static I could set-up Redirects, but in this case they are fully dynamic.

I also need to keep the URI after the user loads the page, so it cannot change back to /statistics during loading.

3
  • Do you mean Sitecore will have page /Home/Statistics. But January, February, etc. are not pages and will serve content dynamically? Mar 9 '17 at 13:20
  • @YogeshPatel correct. The 'Statistics' page will change based on the parameter.
    – user1475
    Mar 9 '17 at 13:21
  • 2
    As mentioned in slack, i think Wildcard is what you are looking for. community.sitecore.net/technical_blogs/b/… Mar 9 '17 at 13:23
5

You can use Sitecore Wildcard item. For that, create an item with name of * inside /Home/Statistics item (/sitecore/content/Home/statistics/*). Remember, the * item (wildcard item) should not have any sibling. And, assign required presentation details to the item to show relevant statistics.

Now, when you request the page e.g. http://example.com/statistics/january, you will get the page context, and based on the parameter (january/fabruary, etc.) you can use your renderings to change content accordingly.

Read more on - http://blog.martinmiles.net/post/wildcard-items-pages-with-mvc-passing-the-correct-datasources-based-on-requested-item-url

2
  • Hm... After quickly trying it out it seems that this won't work for longer paths like /*/*/*/*/*? E.g. if I want to open /statistics/january/10/12/21/44
    – user1475
    Mar 9 '17 at 13:27
  • For longer paths, you can create hierarchy of wildcard items. The hierarchy of wildcard items must be more than or equal number of parameters. Like, /statistics/Jan/01 needs /statistics/*/* /statistics/Jan/01/am needs /statistics/*/*/* and so on Mar 9 '17 at 13:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy