Developer forum

Forum » Development » template path - clean approach

template path - clean approach

Nuno Aguiar
Reply
Hi,

When setting a template we have to do something like:
Dynamicweb.Templatev2.Template template = new Dynamicweb.Templatev2.Template("MyModule/" + Properties.Values["SampleTemplate"].ToString());

However, we sometimes use sub-folder under "MyModule" and would like to get the template in a standard way, so we use the _path settinf, for example
Dynamicweb.Templatev2.Template template = new Dynamicweb.Templatev2.Template(Properties.Values["SampleTemplate_path"].ToString().Replace("Files/Templates/",""));

But as you can see we need to remove the "Files/Templates" otherwise it won't work. Is there a way to do this simpler/cleaner? So if we changed the "Folder" attribute in the _Edit, everything would work, without having to manipulate the string?

Best Regards,
Nuno


Replies

 
Nicolai Høeg Pedersen
Reply
You should be able to do that the same way regardless if you are using subfolders or not.

In the Gallery module we do like this:
<dw:FileManager ID="ListTemplate" runat="server" Folder="/Templates/Gallery/List" />

And in the code:
t = New Template("Gallery/List/" & Properties.Value("ListTemplate"))

Be aware that there are 2 different filemanager controls - use the one above, and do not set the fullpath=true on it.

 

You must be logged in to post in the forum