3

I am working with Umbraco and was wondering whether there is a easy way to create a site wise settings node.

At the moment I have this tree structure.

  • Content
    • Home
    • Item 1
    • Item 2
      • Item 2a

What I would like to create is something like this

  • SITE WIDE CONTENT
  • Content
    • Home
    • Item 1
    • Item 2
      • Item 2a

Site Wide Content will contain something like Google Analytics Url, that the user can change easily.

Is there a way to accomplish this?

harnamc
  • 541
  • 6
  • 20
  • Is it possible for you to move your "Item" nodes to under the Home node? Then voila, the Home node can contain all site wide settings. That's the usual way of doing it. – Jannik Anker Jan 20 '16 at 07:26
  • Hi Jannik, that is how I am doing it at the moment, However I have looking for a node where a user can input data that can be used site wide. Like "Fetured Items" (User can select 4 nodes to go in the fetured section) "Google Analytics Url" (User can input URL) – harnamc Jan 20 '16 at 11:31

1 Answers1

8

EDIT: See bottom for a method for handling page redirects and 404 errors resulting from templateless nodes...

A common node structure may look like this which allows for site specific content - the advantage here is that all the site content resides under the home node and users can't create more content in the root (provided you've set things up properly):

  • Home [Contains Settings Tab]
    • Page 1
    • Page 2
    • Contact Us
    • About

Depending on how much site wide settings information, you could create a Settings tab on the Home DocumentType and store it all there (as illustrated above); or create a tree structure using a Settings node (as illustrated below):

  • Home
    • Page 1
    • Page 2
    • Contact Us
    • About
    • Settings [has General Settings tabs/properties]
      • Email Templates [Store other nodes that represent mail merge template for example]

Alternatively, for Global Settings/Content (where I might have multiple sites) I frequently create a separate node structure at the root to contain global settings, email templates, etc.:

  • Home
    • Page 1
    • Page 2
    • Contact Us
    • About
  • Settings [has GlobalSettings tabs/properties]
    • Email Templates [Store other nodes that represent mail merge template for example]

Create a Settings DocumentType to act as a folder or container, but don't give it a template and all your global/site-wide settings/data content can be organised under that.

Handling Nodes without Templates

DocumentTypes that are created without assigning/creating a Template for them (as in the case of say the Section node at the base level of the tree and it's children) will throw a 404 error when someone attempts to visit it's URL, and thus should be excluded from any navigation rendered in the website. Any user manually entering the URL that you would expect to find the node at, e.g. /settings will be presented with the default 404 error page as it doesn't exist.

There are a few ways to mitigate this:

  1. Add a property to the DocumentType with the alias umbracoRedirect and using the ContentPicker DataType;

  2. Create a custom 404 Error page and set up the Umbraco configuration to use that instead of the default.

If you use the first option, you can set the page that you want the user to see by default - generally the Home page.

The second option can be good if you have some custom logic (like finding closest matching page based on URL) in your 404 error page, or use something like SEO Checker to handle 404 errors and redirects for you.

A lot of this is mitigated by simply making sure those nodes aren't visible via their URL in the website at all, which can be done by coding your navigation structures (menu's, sitemaps, etc.) to exclude them.

Note: I generally make sure they are also excluded by any sitemap.xml generators so that search engines don't attempt to index them. You can also add them to your robots.txt files as well.

Community
  • 1
  • 1
Robert Foster
  • 2,317
  • 18
  • 28
  • Excellent, thanks Robert. Quick question: is there a way to stop users navigating to node created? for example if I create a node "Settings" at the root the url of it will be domain/settings. is there a way to no throw a 404 error instead of doing a URL redirect to /home? – harnamc Jan 20 '16 at 11:29
  • If users would try to go to the mentioned node, they should be thrown an 404 error, since this url doesn't exist: domain/settings. If you would like to redirect them to Home when going to domain/settings, you should set a [custom route](https://our.umbraco.org/documentation/reference/routing/custom-routes). – Marko Jovanov Jan 20 '16 at 15:26
  • @MarkoJ. yes - there's a few ways to handle the 404 errors; personally I use SEOChecker and a custom 404 error page; but have also in the past, as you mentioned, set a redirect on those pages that don't have templates. – Robert Foster Jan 21 '16 at 04:14
  • Can we access the property (such as settings) of the parent node in a strongly typed manner (using model builder)? – MIWMIB Oct 23 '17 at 09:27
  • Absolutely - the `IPublishedContent` object has a Parent (or ParentId) property, and you can retrieve that object as a strongly typed model using the Umbraco API. – Robert Foster Oct 24 '17 at 00:59