Trying to get the doctype alias based on the generated model's name, but I'm absolutely not sure if this is "the way"...
(Among other things, I'm not sure if the lowercase alias as key possibly could generate a duplicate key exception.)
Hi Ulf, perhaps I am misunderstanding what you are trying to do, but if you already have a published content model you should be able to get its content type alise like this:
//If you have an instance of the content you could get it like this
var type = Model.ContentType.Alias;
//or if you don't have an instance and need to know an arbitrary type you can do this
var type2 = ContentModels.MyModelType.ModelTypeAlias;
Follow up with more details of how you would want to use your method above if neither of these work for your situation.
But now, I think I'll drop the generic and go with a configuration with a dictionary like { Controls.ModelTypeAlias, "Kontroller" },{ Archive.ModelTypeAlias, "Arkiv" }, {...}, ... easy added to in the future and just run them through.
Get the Document Type Alias by Type
Trying to get the doctype alias based on the generated model's name, but I'm absolutely not sure if this is "the way"... (Among other things, I'm not sure if the lowercase alias as key possibly could generate a duplicate key exception.)
Any other suggestions?
Hi Ulf, perhaps I am misunderstanding what you are trying to do, but if you already have a published content model you should be able to get its content type alise like this:
Follow up with more details of how you would want to use your method above if neither of these work for your situation.
Hi James,
Isn't that obvious??? :-)
I was looking to streamline the creation of several sub types on a parent save event with this method:
Instead of doing this for 10 (possibly more) sub types
But now, I think I'll drop the generic and go with a configuration with a dictionary like
{ Controls.ModelTypeAlias, "Kontroller" },{ Archive.ModelTypeAlias, "Arkiv" }, {...}, ...
easy added to in the future and just run them through.This is also a part of updating existing entries.
is working on a reply...