0
votes

I am trying to setup a framework for A/B Testing on Umbraco. In order to write the script that rotates the templates evenly for a given document type, I will need to know what the allowed templates for the page are (since I may not know the template names in advance). Is there a way to get this using Razor?

For example, landing page has been allowed Template A, Template D (and maybe Template C in the future) in the Settings section for that document. How can i retrieve Template A, Template D from Umbraco?

Thanks in advance!

1
What version of umbraco are you using?Douglas Ludlow
umbraco v 4.11.9 (Assembly version: 1.0.4898.17344)holaworld
Sorry it took me so long to respond...Douglas Ludlow

1 Answers

0
votes

Sure, you can do anything from razor:

@using umbraco.cms.businesslogic.template
@using umbraco.cms.businesslogic.web
@inherits umbraco.MacroEngines.DynamicNodeContext
@{
    int doctypeId = 1048;
    DocumentType doctype = new DocumentType(doctypeId);
    Template[] templates = doctype.allowedTemplates;

    <h3>Default Template</h3>
    @doctype.DefaultTemplate<br /><br />

    <h3>Allowed Templates</h3>
    foreach (var template in templates)
    {
        @:@template.Id, @template.Alias, @template.Text<br />
    }
}