Document type 'x' has a default template 'x' but...
Hi,
Could you please expand on this error message
"Document type 'ContentPage' has a default template 'ContentPage' but that template does not use this document type"
I have a DocType called "ContentPage" and a master template with this DocType set as the default template as below:
public partial class ContentPage: Vega.USiteBuilder.TemplateBase<Company.NameOfSite.Web.DocumentTypes.ContentPage>
This problem occurs as these DocType can have multiple templates, so I set the AllowedTemplates as per documentation:
AllowedTemplates = new string[] {"Search"}
However, I'm not sure if this is by design, but if I specify the allowed template as above then the default template for 'ContentPage' doc type does not get set.
So I try to fix this by explicitly setting the default:
AllowedTemplates = new string[] {"Search"}, DefaultTemplate = typeof(ContentPage),
However this causes the error message as above.
Any futher explaination would be greatly appreciated.
If your template and document type have the same name (ContentPage) than in above code you must include your template's namespace.
BTW, if you have only one template that renders ContentPage, than you don't have to set DefaultTemplate property at all - it'll be set automatically by uSiteBuilder.
Thanks for your reply, I've since changed the set up but I'll get the error message to appear again and post my template code.
With regards to "BTW, if you have only one template that renders ContentPage, than you don't have to set DefaultTemplate property at all - it'll be set automatically by uSiteBuilder."
I believe there may be a bug here, if I do not set any "AllowedTemplates" then the default template gets set automatically via the template, however with "AllowedTemplates" the default does not get set. Can you please confirm if thisis by design or if this a bug?
Hi Rich, yes you noticed this well - if you set AllowedTemplates to any value, it overrides default behaviour of uSiteBuilder so uSiteBuilder it's not setting DefaultTemplate automatically. Did you try to set it explicitly (through DefaultTemplate property) ? Can you paste the code?
Eventhough it is designed like that, I'd say that this is a bug and that we should change it - we didn't put enough attention into AllowedTemplates property as we are not really using it often. In Vega, we prefer strongly typed approach (as AllowedTemplates is just a string property, there is no compile time check if you set template(s) name(s) correctly).
I have a couple of more questions, these are mainly as I’m
trying to migrate an existing project into uSiteBuilder.
I’ve built an import
tool which works perfectly for DocTypes/properties/mandatory/validation but it’s
the templates / default templates that are not working out so
well.
Ideally right now I'd love to just use uSiteBuilder for DocTypes. However without strongly typed templates its not
possible to specify the default template.
It would great just set the DefaultTemplate via a
string property. Is this possible or could you point me to where I can
tweak the code to make this happen? (I'm hoping I might be able to tweak the
'Allowed Templates' code)
fyi I'm not using code behind (I prefer Razor) so I just XCOPY my templates for deployment, and also this
project I use uComponents RenderTemplate heavily http://ucomponents.codeplex.com/wikipage?title=RenderTemplates and in initial testing it seems they don't seem to play nicely together.
Out of interest (this one maybe my lack of understanding) I often have
templates which are not related to a DocType (for example xmlSiteMap) do I
always have to specify a DocType per template to have the template included in
uSiteBuider?
Sorry for the long post, I appreciate I might be trying to shoehorn my
project into uSiteBuilder but would love to get it all working for deployment
purposes.
As you noticed, without using strongly typed templates currently it's not possible to set DefaultTemplate but you can always do it manually. We'll add string property for setting up default template in the next version but it'll be in the source code on Codeplex even before. If you want to change the code by yourself, you can do it in Vega.USiteBuilder/DocumentTypeBuilder/DocumentTypeManager.cs, line 226. That's the place where this functionality is done.
About always assigning template to a DocType, that's not necessary. The only required thing is that your template subclasses TemplateBase class and it'll be added to Umbraco automatically.
Hi Vladan, I also have this issue, I wonder if you could expand on the solution? I could not work it out from your above message. My DocType and template have the same name:
Doc Type declaration:
[DocumentType( AllowedChildNodeTypes = new Type[] { typeof(Project.Web.DocumentTypes.Content) }, AllowedTemplates = new string[] { "AltTemplate" }, DefaultTemplate = typeof(Project.Web.Masterpages.Content) ) ] public class Content: Project.Web.DocumentTypes.Master
Masterpage declaration:
public partial class Content: Vega.USiteBuilder.TemplateBase<Project.Web.DocumentTypes.Content>
There error I receive is
Document type 'Content' has a default template 'Content' but that template does not use this document type
Document type 'x' has a default template 'x' but...
Hi,
Could you please expand on this error message
"Document type 'ContentPage' has a default template 'ContentPage' but that template does not use this document type"
I have a DocType called "ContentPage" and a master template with this DocType set as the default template as below:
This problem occurs as these DocType can have multiple templates, so I set the AllowedTemplates as per documentation:
However, I'm not sure if this is by design, but if I specify the allowed template as above then the default template for 'ContentPage' doc type does not get set.
So I try to fix this by explicitly setting the default:
However this causes the error message as above.
Any futher explaination would be greatly appreciated.
Many thanks again for a great tool
Cheers
Rich
Hi Rich, can you paste how your template looks?
The problem is probably related with how you declared your template - it has to be declared as
and content type should be declared as:
.
If your template and document type have the same name (ContentPage) than in above code you must include your template's namespace.
BTW, if you have only one template that renders ContentPage, than you don't have to set DefaultTemplate property at all - it'll be set automatically by uSiteBuilder.
Hi Vladan,
Thanks for your reply, I've since changed the set up but I'll get the error message to appear again and post my template code.
With regards to "BTW, if you have only one template that renders ContentPage, than you don't have to set DefaultTemplate property at all - it'll be set automatically by uSiteBuilder."
I believe there may be a bug here, if I do not set any "AllowedTemplates" then the default template gets set automatically via the template, however with "AllowedTemplates" the default does not get set. Can you please confirm if thisis by design or if this a bug?
Many thanks
Rich
Hi Rich, yes you noticed this well - if you set AllowedTemplates to any value, it overrides default behaviour of uSiteBuilder so uSiteBuilder it's not setting DefaultTemplate automatically. Did you try to set it explicitly (through DefaultTemplate property) ? Can you paste the code?
Eventhough it is designed like that, I'd say that this is a bug and that we should change it - we didn't put enough attention into AllowedTemplates property as we are not really using it often. In Vega, we prefer strongly typed approach (as AllowedTemplates is just a string property, there is no compile time check if you set template(s) name(s) correctly).
I’ve built an import tool which works perfectly for DocTypes/properties/mandatory/validation but it’s the templates / default templates that are not working out so well.
It would great just set the DefaultTemplate via a string property. Is this possible or could you point me to where I can tweak the code to make this happen? (I'm hoping I might be able to tweak the 'Allowed Templates' code)
fyi I'm not using code behind (I prefer Razor) so I just XCOPY my templates for deployment, and also this project I use uComponents RenderTemplate heavily http://ucomponents.codeplex.com/wikipage?title=RenderTemplates and in initial testing it seems they don't seem to play nicely together.
Rich
Hi Rich,
As you noticed, without using strongly typed templates currently it's not possible to set DefaultTemplate but you can always do it manually. We'll add string property for setting up default template in the next version but it'll be in the source code on Codeplex even before. If you want to change the code by yourself, you can do it in Vega.USiteBuilder/DocumentTypeBuilder/DocumentTypeManager.cs, line 226. That's the place where this functionality is done.
About always assigning template to a DocType, that's not necessary. The only required thing is that your template subclasses TemplateBase class and it'll be added to Umbraco automatically.
Hey Vladan,
Thanks for replying, this sounds great.
Also thanks for the further info on TemplateBase, can't wait to get this all working on my project.
Rich
Just like to clarify that uComponents RenderTemplate works fine with uSiteBuilder, my mistake.
Rich
Hi Vladan, I also have this issue, I wonder if you could expand on the solution? I could not work it out from your above message. My DocType and template have the same name:
Doc Type declaration:
[DocumentType(
AllowedChildNodeTypes = new Type[] { typeof(Project.Web.DocumentTypes.Content) },
AllowedTemplates = new string[] { "AltTemplate" },
DefaultTemplate = typeof(Project.Web.Masterpages.Content)
)
]
public class Content: Project.Web.DocumentTypes.Master
Masterpage declaration:
public partial class Content: Vega.USiteBuilder.TemplateBase<Project.Web.DocumentTypes.Content>
There error I receive is
Document type 'Content' has a default template 'Content' but that template does not use this document type
is working on a reply...