Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can't retrieve the <code>DocumentType</code> hierarchy from the published cache, i.e. from the <code>Node</code> or <code>IPublishedContent</code> objects.</p> <p>However, what you could do is:</p> <ol> <li><p>On application start generate a <code>Collection&lt;DocumentType&gt;</code> object of all the content (not media, member) <code>DocumentType</code> objects and cache it. I certainly wouldn't do this from the UI as querying the DocumentType will cause calls to the database, so caching and reusing the objects is much better.</p></li> <li><p>Possibly add the same code to the AfterNew event of a <code>DocumentType</code>. This way new <code>DocumentType</code> objects are also added to the cached list.</p></li> <li><p>Create an extension method like the existing <code>IsDocumentType(string documentTypeAlias)</code> which queries the cached list.</p></li> </ol> <p>The following code will retrieve the parent structure, you just need to add a <code>while(docType.MasterContentType != null)</code> construct:</p> <pre><code>DocumentType docType = DocumentType.GetByAlias("ContentPage"); DocumentType parentDocType = new DocumentType(docType.MasterContentType);` </code></pre> <p><strong>Edit:</strong></p> <p>If you want to go down the root of having a property on the <code>IPublishedContent</code> or <code>Node</code> instance then I would adopt a similar approach.</p> <ol> <li><p>Have all doc types inherit from a single doc type which has a label property called <code>parentDocTypeAliases</code>.</p></li> <li><p>On the <code>Newing</code> event of a <code>Document</code>, add the aliases of the parent doc types as a cmma delimited list to the <code>parentDocTypeAliases</code> property. You'll still need the code listed above to query the doc type hierarchy.</p></li> <li><p>Create a new extension method (e.g. <code>InheritsFromDocumentType(string documentTypeAlias)</code>) that queries the csv value.</p></li> </ol>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload