When you make a new DocumentType in umbraco you have the option to specify a Master Document Type. It seems to work pretty much like object inheritence. Any custom properties on the Master Document Type are inherited by the new Document Type. In my case I have a document type of Event and then a few sub types like Sporting Event, Fundraiser, etc, that inherit from the Event sub type. Further down the line I need my template to be able to walk up the tree node structure to find the event its under. To do this I think I need to know the nodes master document type.
When working with actual document based on a document type, in xslt, razor scripts or the API, there will be no trace of the document type inheritance.
Each document based on one of the event subdocument types will simply have all the properties from the master document type so if you have:
Event document type - Date property - Name property
Sporting event document type : with event as master document type - Sport property
A published document of type sporting event will have all properties mentioned above
<!-- In xslt you can do the following when $curentPage is a sporting event -->
<xsl:value-of select="$currentPage/date" />
<xsl:value-of select="$currentPage/name" />
<xsl:value-of select="$currentPage/sport" />
// Using the NodeFactory in the API you can do this
var node = umbraco.NodeFactory.Node.GetCurrent();
string name = node.GetProperty("name").Value;
DateTime date = DateTime.Parse(node.GetProperty("date").Value); // but use a more safe method like TryParse
string sport = node.GetProperty("sport").Value;
How to get INode's Master Document Type
I am getting the current node from umbraco.NodeFactory.Node.GetCurrent() How can I get the Master Document Type of the node?
Hi greengiant83,
What exactly do you mean by Master Document Type? :-) Is it the document type of the current node, or?
Thanks!
/ Bo
When you make a new DocumentType in umbraco you have the option to specify a Master Document Type. It seems to work pretty much like object inheritence. Any custom properties on the Master Document Type are inherited by the new Document Type. In my case I have a document type of Event and then a few sub types like Sporting Event, Fundraiser, etc, that inherit from the Event sub type. Further down the line I need my template to be able to walk up the tree node structure to find the event its under. To do this I think I need to know the nodes master document type.
Hi Green Giant ;)
When working with actual document based on a document type, in xslt, razor scripts or the API, there will be no trace of the document type inheritance.
Each document based on one of the event subdocument types will simply have all the properties from the master document type so if you have:
Event document type
- Date property
- Name property
Sporting event document type : with event as master document type
- Sport property
A published document of type sporting event will have all properties mentioned above
Regards
Jesper Hauge
is working on a reply...