Umbraco site wide settings node - c#

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, 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:
Add a property to the DocumentType with the alias umbracoRedirect and using the ContentPicker DataType;
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.

Related

How to apply a multi-document template

The general process
Documents are uploaded to DocuSign creating a new Envelope.
Templates are applied to this Envelope.
Recipients are updated to make sure there is no mixup with signers from the template
The Envelope is sent to the signers.
Intended use of templates
The primary use of templates is to allow users to upload documents and use all other information from templates like fields and other setting for the uploaded documents. Signers can also be freely set and overwrite the ones defined in the template.
For applying templates we use https://developers.docusign.com/docs/esign-rest-api/reference/envelopes/envelopetemplates/applytodocument/
The Template
The template consist of 2 documents. The first document has 3 pages and the second document has 2 pages.
There is one signer. A signature box is added to the last page of both documents.
The Problem
Test scenario: The exact same documents as in the template. This results in the signature box on the second document is not set.
Test scenario: Use the 3 page file for both documents. This results in the signature box being put on page 3 of both documents. So it looks like the assignment works only from document 1 to all the other documents
Test scenario: Use different 3 page documents that match the template for both documents. The result is the same as in the 2. test scenario.
What I tried
The described scenarios are based on this (simplyfied) code for applying the templates:
//variables envAPI (class EnvelopesApi), accountId, templateId and envelope (class Envelope) are already set
DocumentTemplateList templateList = new DocumentTemplateList();
templateList.DocumentTemplates = new List<DocumentTemplate>();
templateList.DocumentTemplates.Add(new DocumentTemplate()
{
TemplateId = templateId,
DocumentId = "1"
});
envAPI.ApplyTemplateToDocument(accountId, envelope.EnvelopeId, "1", templateList);
templateList = new DocumentTemplateList();
templateList.DocumentTemplates = new List<DocumentTemplate>();
templateList.DocumentTemplates.Add(new DocumentTemplate()
{
TemplateId = templateId,
DocumentId = "2"
});
envAPI.ApplyTemplateToDocument(accountId, envelope.EnvelopeId, "2", templateList);
//some recipient checking is done here
envAPI.Update(accountId, envelope.EnvelopeId, envelope);
I also tried using more entries in templateList.DocumentTemplates but that only caused INVALID_REQUEST_BODY errors.
I realized the DocumentID property of the documents in the templates are very different after the first file. My test template has 1 for the first document and the ID of the second document is a very large number. Using this large number also causes INVALID_REQUEST_BODY errors.
Is this actually correct and the error is somewhere else? Because it looks like it should work this way. Or is the problem located somewhere else?
The workflow that you are trying is a perfect place to use a composite template. The recommendation is use one composite template per document. In one POST envelopes call you can swap out the documents on the templates with documents at runtime and apply server (saved) templates to the documents. You can add recipients, drop recipients by not including them, and also add tabs or write values to tabs at runtime. See:
https://www.docusign.com/blog/dsdev-from-the-trenches-composite-templates
https://www.docusign.com/blog/dsdev-why-use-composite-templates
To answer my own question: This doesn't work. At least not this way.
Yes, composite templates are one way of dealing with this requirement but then again, why do multi-document templates even exist?
So the answer is quite simple: Do it the other way around.
To use a multi-document template properly, the template needs to be the starting point. Use a template and replace the files to create an evenlope instead of creating an envelope first and then applying templates to the envelope.

Umbraco Architecture with query string parameters for document

I have a client web app that I've been asked to make some updates to. I have a small number of development hours to work within so a redesign of the system is not an option at this time.
The app was written using classic asp with logic to pull certain content dynamically from a custom database and to write back certain user actions to the same custom database. There is an admin area for viewing these logged user actions.
At some point in time portions of the web app were migrated to use Umbraco 4 for the cms. I've been tasked with migrating some additional content, that is still being pulled from the original custom database, into the context of the CMS.
The content in question is structured so that the content node's document type points to a special masterpage. The master page has codebehind logic that checks for a query string parameter and uses that parameter to query the database for content specific to that parameter. In then populates one specific section on the page with that content.
The logic also uses the query string parameter when writing user actions back to the custom database.
I need to maintain the url syntax and behavior of writing user actions back to the custom database but move the displayed content specific to that parameter into the CMS somewhere. Where should I place this content in the CMS and how can I access it from those pages via the query string parameter?
Url Examples:
/site_home/Node1/Node2/Node3/
/site_home/Node1/Node2/Node3/?partner=partner1
/site_home/Node1/Node2/Node3/?partner=partner2
/site_home/Node1/Node2/Node3/Review/
/site_home/Node1/Node2/Node3/Review/?partner=partner1
/site_home/Node1/Node2/Node3/Review/?partner=partner2
/site_home/Node1/Node2/Node3/Checkout/
/site_home/Node1/Node2/Node3/Checkout/?partner=partner1
/site_home/Node1/Node2/Node3/Checkout/?partner=partner2
If you can provide a bit clearer explanation of what you are trying to accomplish, I am sure that I can assist you further. However, the code below and link to the discussion from which I pulled it may help get you on the path. Give me some feedback or edit your question and I will edit my answer to assist.
#{
if(!string.IsNullOrEmpty(Request.QueryString["query"]))
{
int result= 0;
if(Int32.TryParse(HttpContext.Current.Request.QueryString["query"].ToString(), out result))
{
umbraco.MacroEngines.DynamicNode node = new umbraco.MacroEngines.DynamicNode(result);
<h1> #node.Name </h1>
}
else
{
<h2>No query found</h2>
}
}
}
Umbraco Forums - Render Node content from querystring

How do I create an mvcsitemap that displays a dynamic name

Really struggling with this and not finding much helpful stuff on google.
I set up a sitemap, and I want some breadcrumbs such that url:
/CatManagement/Cats/38
displays breadcrumbs
Cat Management > Cats > Mr. Fuzzy Wuzzy
I don't quite understand what the sitemap node structure would be for this as the 38 is sort of a parameter of Cats.
In the dynamicNodeProvider I created I can probably grab the ID somehow and do a quick lookup to get the name, but I am not sure how to bring it all together.
Any ideas?
Have a look at Routing Basics in the MvcSiteMapProvider wiki. You just need to ensure that your parameter (38) is preserved from the current request, the node matching logic already takes into consideration action method parameters. That example shows how you would do that using a custom dynamic node provider, but I recommend reading the entire document as understanding it is key to making MvcSiteMapProvider work.
I have also created a more in depth look at the problem here with working demos for download: http://www.shiningtreasures.com/post/2013/09/02/how-to-make-mvcsitemapprovider-remember-a-user-position

Url Routing Asp.net from hierarchical tree of pages stored in a database

Ok
I have a bunch of html pages stored in a mssql database. Each row has:
ID
PageTitle
Page Html Content
ParentId
ParentId is there so i can create a hierarchical tree of pages.
Currently i am using this line of code in order to access the pages...
routes.MapPageRoute("front", "{PageTitle}", "~/front.aspx");
Which then causes a redirect to front.aspx so i can then use:
Page.RouteData.Values["PageTitle"].ToString()
In order to grab what i need so i can display the appropriate page in the browser.
However, can anyone suggest how i would amend 'routes.MapPageRoute' so it supports an infinate hierarchical tree like i have in my database. Essentially i want to be able to type a url like: http://localhost/PageOne/SubPageOfPageOne etc
Changed:
routes.MapPageRoute("front", "{PageTitle}", "~/front.aspx");
to this:
routes.MapPageRoute("front", "{*PageTitle}", "~/front.aspx");
this pulls everything that is in the url (past the domain the name)...
then i used the split function to recursively get each node so i could check if it exists.

Bread crumbs with url rewriting

In database I have a list of hierarchical list of categories so i construct a Custom Sitemap provider (by extending StaticSiteMapProvider ) with this list of categories.
Now, the page that display articles /ShowArticle.aspx?id=" + Eval("ID") is rewrited into:
/id/article-title.aspx.
So it's not physical exists.
I want the following: When the selected page is displayed I want to display the complete category path in the "Bread crumbs" (every article has a "category" property that contains it's 1 lvl category - without parents)
For example categories structure:
Home
Products
CdRom
DvdRom
Toshiba
Support
Hardware
Software
When an article id=xx,category=Toshiba, title="Best Toshiba DVD" is opened, the path in "Bread crumbs" should be:
Home|Products|DvdRom|Toshiba|Best Toshiba DVD
How to do it? Should I add something to my custom Sitemap provider?
I don't get any answers :(
Maybe I should do like this:
Instead constructing the site map for categories, i should construct it both for categories and all available articles in the database.
It's not efficient (even with caching), but it's the only way i think.
What else can I do?
Update:
What is left is just to create dynamically list of links that will act as bread crumbs,
when an article is opened it's containing category will be read and full hierarchical categories path will be calculated (from root to this current node).
I had to look up what the SiteMap provider was, and in doing so accidently came across the answer you may be looking for on the MSDN website: Breadcrumb using SiteMapPath Class
It might not be quite what you are after but it could be a point in the right direction :)

Categories

Resources