Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Utte 7 posts 27 karma points
    Apr 03, 2014 @ 15:46
    Utte
    0

    Easiest way to get www.x.com/article/name

    Hi! I'm new to Umbraco and are looking for advice. I want to know the easiest and best way in Umbraco to show article details on a site with the article name in the URL.

    For example: I have a database with a Artists table. I have a page on my site with a list of the artists. When i click on one artist i want to get to "www.x.com/artists/artistname" with artist details.

    Any suggestions?

    /Utte

  • Chris Perks 32 posts 114 karma points
    Apr 03, 2014 @ 16:17
    Chris Perks
    0

    Umbraco will, by default, look for an item on the content tree that follows the convention:

    Content
    --> Artists
    ----> Artist 1
    ----> Artist 2
    ----> Artist 3

     

    And so on. If those items don't actually exist as Umbraco content items, then you'll want to create some standard MVC controllers which fetch data from your database and populate a view - essentially bypassing Umbraco's processing.

    You can tell Umbraco not to process certain Url's by using the umbracoReservedPaths setting in your Web.Config:

     <add key="umbracoReservedPaths" value="~/umbraco,~/install/,~/artists" />

    At this point, you're free to set up your own MVC routes and controllers, just like you would in any other project.

  • Utte 7 posts 27 karma points
    Apr 03, 2014 @ 21:21
    Utte
    0

    Thank you Chris, I will try it out tomorrow.

  • Robert Mulder 79 posts 272 karma points c-trib
    Apr 03, 2014 @ 21:45
    Robert Mulder
    0

    At the risk of hijacking a thread I have a similar question. Lets say in the above example you'd have Umbraco set up like this:

    Content
    --> Artists
     ----> Artist
    

    Where Artist is a page where I'd like to display the content of a table completely unrelated to Umbraco. I could ofcourse use query string variables to differentiate:

    /Artists/Artist/?id=1234
    

    But for SEO purposes I'd much rather get a URL like this:

    /Artists/Artist/1234/Name-of-the-artist/
    

    But then have Umbraco render the template that is associated with the /Artists/Artist/ url. I suppose URL rewriting could (and probably should) be used here, but

    1. I don't know how I should go about configuring this in Umbraco
    2. Both the name Artists as well as Artist are just Umbraco nodes and can be renamed by the end user at will.

    I'm sure one of you is brilliant enough to help me out with a solution to these issues.

  • Utte 7 posts 27 karma points
    Apr 04, 2014 @ 09:37
    Utte
    0

    When i my add artist to umbracoReservedPaths in web.config and try to open the page i get "HTTP Error 404.0 - Not Found The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.". Does anyone know what the problem is?

  • Chris Perks 32 posts 114 karma points
    Apr 04, 2014 @ 10:08
    Chris Perks
    0

    @Utte - you'll need to create a route to your controller, in the usual MVC fashion (see here: http://www.asp.net/mvc/tutorials/older-versions/controllers-and-routing/asp-net-mvc-routing-overview-cs)

    You're essentially ending up a with a hybrid of an Umbraco site and a regular non-Umbraco MVC site - but as long as you keep your routing, controllers and views organised consistantly, there's nothing wrong with this approach.

     

  • Chris Perks 32 posts 114 karma points
    Apr 04, 2014 @ 11:17
    Chris Perks
    0

    @Robert Mulder

    This should be possible with some custom routing, I'll have to have a dig around in some code and post later.

  • Robert Mulder 79 posts 272 karma points c-trib
    Apr 04, 2014 @ 11:24
    Robert Mulder
    0

    Thanks Chris, I appreciate any help you can provide.

  • Utte 7 posts 27 karma points
    Apr 04, 2014 @ 12:03
    Utte
    0

    @Chris Perks

    Thank you for your help. Unfortunately I'm pretty new to MVC and can't get the routing to work. I have a controller named "ArtistsController", and i want to run the Index method in it with an id; like Artists/Index/3. It would be terrific if you or someone else could show me how I should do the routing, or show me slightly more detailed guide. 

Please Sign in or register to post replies

Write your reply to:

Draft