简体   繁体   中英

Umbraco site wide settings node

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?

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, eg /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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM