1
votes

I'm trying to re-create a website using Umbraco. For this website I have news items which I am storing in a node outside the webroot:

  • Content
    • Website Home
      • News
    • Newsmessages
      • Message 1 (created 10-10-2011)
      • Message 2 (created 15-01-2012)

I would like to use URL parameters to filter the list of newsitems to show or to show the actual news item.

  1. Shows news section:

www.website.com/news

  1. Shows news list for 2011:

www.website.com/news/2011

  1. Shows news list for October 2011:

www.website.com/news/2011/10

  1. Shows news detail for Message 1:

www.website.com/news/2011/10/10/message-1

Can this be done without having to create all content items below /Content/Website Home/News?

2

2 Answers

3
votes

You can add new Area in Umbraco 5 jupiter and add Custom routes in Arearegisteration.cs, there is a package by Sebastiaan Janssen Jupiter as visual Studio Plugin

http://our.umbraco.org/projects/developer-tools/jupiter-as-visual-studio-solution

Use this to convert your web app to MVC application and Right Click on the Area Folder and add a new Area, VS will take care of the rest. Then add Controller and Custom Routes in AreaRegisteration.cs For example

context.MapRoute(
"ROUTE",
"/{action}/{year}",
new { controller = "ControllerName" }
);

if Url is www.website.com/news/2011, the action must be named news and yer will be passed in query string, you can play as you want with the URL.

Hope that Helps,

Sher

2
votes

This isn't possible out of the box with Umbraco. One way this could be accomplished, however, is by use of URL rewrites. You can rewrite your parameters to a query string which can be read by a macro which then, in turn, displays the desired news item(s).

So,

www.website.com/news/2011

...would be rewritten as something like:

www.website.com/news?year=2011

...and

www.website.com/news/2011/10

...would be rewritten as:

www.website.com/news?year=2011,month=10

..and so on.

The macro on the 'news' page would read the requests from the query string and write out the filtered results.