Copied to clipboard

Flag this post as spam?

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


  • Michaël Vanbrabandt 863 posts 3348 karma points c-trib
    Oct 21, 2016 @ 06:39
    Michaël Vanbrabandt
    0

    Umbraco content structure advice

    Hi all,

    we are working on a new project which is a website that contains many company details over different categories. You have bars, restaurants, shops, juwelers, garages, and so on.

    For the content structure we would like to be able that the company is reached by

    http://www.example.com/company-name/

    but it can also be accessed by using the category:

    http://www.example.com/restaurant/company-name/

    or when it belongs to multiple categories:

    http://www.example.com/lounge-bar/company-name/

    So we need to create document types for the category and for the company nodes.

    Where the company node has a link to the categories it belongs to by having a multi node treepicker.

    But how will be setting up this content structure? So we start with the home node and then? We can't just putting categories and company all directly under the home node?

    Or is it better for just allowing http://www.example.com/company-name/ as the link to the company details?

    Any advice?

    /Michaël

  • Michaël Vanbrabandt 863 posts 3348 karma points c-trib
    Oct 21, 2016 @ 07:06
    Michaël Vanbrabandt
    0

    Also we start with primary categories but these can also have subcategories so it is possible to have:

    http://www.example.com/restaurant/

    as primary category and then have

    http://www.example.com/italian-restaurant/

    http://www.example.com/chinese-restaurant/

    as subcategories of restaurant but you see we don't want to put the restaurant in the url so this also need to be put under the home node then or... ?

    /Michaël

  • Jason Vickers 21 posts 115 karma points
    Oct 23, 2016 @ 20:35
    Jason Vickers
    1

    The way that I usually handle this situation is to create a category doctype with a container doctype that houses these categories. For example:

    Categories (doctype container - permissions allow doctype category_

    1. Restaurant (doctype category)
    2. Lounge Bar (doctype category)

    This provides a clean way to manage the categories, then you can create a multinode picker with the categories node set as the default and use that to pick the categories.

    As for the URL's, the easiest way that I have found to handle this, is through a URL rewrite. For example, you could use something like the following:

     <rule name="Category Rewrite" stopProcessing="true">
         <match url="^/?(.*)/(.*)/?$" />
         <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
         <action type="Rewrite" url="/{R:2}/" appendQueryString="false" />
    </rule>
    

    Please note that this is a pretty broad rewrite and used just for an example. You would want to tighten up the Regex and modify to fit your needs. However, this would rewrite the URL to take the business name and load that businesses page. Another way to handle it could be through a query string:

     <rule name="Category Rewrite" stopProcessing="true">
         <match url="^/?(.*)/(.*)/?$" />
         <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
         <action type="Rewrite" url="/business-details/?buinessName={R:2}">
    </rule>
    

    Where business-details is the URL alias to a page that would take the business name a populate the details accordingly.

    Edited, since I saw in the second post that you were asking about the category URLs as well. To make the process as simple as possible, you can adjust the permissions for the categories to allow the creation of categories under a categories node, which would allow the nesting that you are talking about. For example:

    Categories
        -Restaurant
              - Italian Restaurant
              - Chinese Restaurant
    

    As for displaying the restaurants for a given category. You can use the second URL rewrite example to pass the category name to a page that will

    1. Take the category name and retrieve the category ID
    2. Use the category ID to retrieve all restaurants where CategoryProp (multinode tree picker) contains the ID.

    I would handle businesses much the same way. Have a business container node that would accept only the business doctype.

    Cheers, -Jason

  • Micha Somers 134 posts 597 karma points
    Oct 24, 2016 @ 08:18
    Micha Somers
    0

    Hi Michaël,

    Although the urls you mention need to be handled in some way, it is not the most important part of defining the structure. It is something that can be handled and it can be done in several ways in Umbraco.

    First, ask yourselves what is needed for the Content Managers to edit the content. What do they need? What are they allowed to access/edit? etc.

    This will lead you to a suitable structure. After that, you can use

    • IIS url rewrite rules (if rewriting can be done by convention) or

    • UrlProviders and ContentFinders (if application logic is needed to return correct content)

    So, try to setup a manageable structure.

    As Jason Vicker already suggested, in general you can go for Categories and Companies as container doctypes, containing Category and Company doctypes as child nodes.

    Refine the structure in case you need more control. Eg. if content editors are allowed to edit content only for their own company, make sure the structure is setup in a away it is easy to configure access to "their" nodes...

  • Michaël Vanbrabandt 863 posts 3348 karma points c-trib
    Oct 31, 2016 @ 07:19
    Michaël Vanbrabandt
    0

    Hi,

    sorry for the late response!

    I have now setup umbraco to be used like:

    Home
        Contact
        About
        Categories
            Restaurant
            Italian Restaurant
            French Restaurant
            Cinema
        Companies
            Company 1
            Company 2
    

    Where under categories you can add categories or subcategories, eg where Restaurant has no parent assigned and where Italian Restaurant has a property Parent which is the Restaurant category.

    Then for Companies I can define companies and assign categories to it using a multi node picker.

    Now all of this is working fine.

    The nodes Categories and Companies have no template assigned so when you go to this url you get a 404.

    But now I need to setup the url rewriting.

    The following urls are valid:

    http://www.example.com/restaurant/

    http://www.example.com/italian-restaurant/

    http://www.example.com/italian-restaurant/company-1/

    http://www.example.com/french-restaurant/company-1/

    http://www.example.com/about/

    http://www.example.com/contact/

    But when I setup url rewriting for the categories, this will have also an effect for the about and contact pages. How can I prevent this so that the url rewriting only gets involved for the categories?

    /Michaël

  • Micha Somers 134 posts 597 karma points
    Oct 31, 2016 @ 08:20
    Micha Somers
    100

    For the parts that are harder to write with url rewrites, you could use multiple ContentFinders.

    One ContenFinder that searches for the nodes in the root of the structure. If that one doesn't find a matching node, just return null.

    The next ContentFinder will try to find one. This might be a ContenFinder that searches in the sub nodes of your Categories node.

    The order in which you add ContentFinders will help finding the right node.

    Hope this helps you further!

  • Michaël Vanbrabandt 863 posts 3348 karma points c-trib
    Nov 01, 2016 @ 10:44
    Michaël Vanbrabandt
    1

    Hi Micha,

    thanks for the intel!

    I managed to get it working by using 2 contentfinders and 2 urlproviders. One for the categories and one for the companies.

    Have a nice day!

    /Michaël

Please Sign in or register to post replies

Write your reply to:

Draft