I'd like to create a "template picker" datatype that works the same way the template combo box on every content node does - ie. a datatype that shows a list of all allowed templates for that type (document type) of node.
Is there an easy way to lift the combo box already there and turn it into a data type?
@warren, i understand exactly what you are saying, but it would be kinda nice if it could be moved to a 'content' tab instead of burried on the last tab [properties] i like to give clients the ability to use alternate templates, they often forget 'where to switch it' :P
I can understand you wanting to move it perhaps but duplicating it seems pointless.
In my opinion users just need good training/documentation on how to use their site - they will soon get to learn where to rename a node, unpublish it and set a different template style.
I would like, at run time, to decide which template to render.
So if a condition is true it renders template a and if its false it renders b. Instead of hard coding the template node ID I'd like to have a nice simple picker in the content section so if a is true it will render the template specified in the content section, or if b is true it will render another template specified in the content section.
Another example... A page is hit and XSLT detects the caller is an iPhone. Instead of sending a redirect back I would instead like to return the content rendered according to an iPhone template specified by the node in the content section. (NB this example is much simpler than my actual scenario but has the same concept).
I know I could stick everything in XSLT and just render appropriate bits but thats not a very modular solution.
Is there some functionality of alt templates that I'm missing? This must be possible....
Thanks Rich, but its not quite what I'm looking for.
The iPhone altTemplate package works by putting javascript at the top of each page that redirects the client to another page. This means the client downloads the normal content and then gets redirected by javascript (a simplification on my part, I know). What I want is to implement some logic in Umbraco for each request that decides which alternate template to render but I don't want to hard code the template IDs / aliases.
Also, as in my previous post, my motive isn't to create an iPhone template - this is just a simplified example of my concept.
Hiya Edward, So if I understand you. Couldn't you jsut use XSLT with the altTemplate method of /templateAlias.aspx appened to the original node URL to switch to that view?
Sorry thinking about it again.... I still dont understand for the duplicate template picker.
If you want a node to have a certain template you just pick it from the dropdown and that particular ndoe will have that style of template from say the 5 different templates the type of node can have.
I am really missing the point.
Maybe you could explain in depth the scenario you are trying to achieve so I can understand your needs better.
Ok, I can't really elabourate on the exact details but here's the scenario:
1. I go to www.mysite.com/page
2. This page has, for example, 5 different templates and the template that is required isn't known until runtime.
3. My plan is to have one template (the default one) which calls some XSLT / control that implements the business logic of which template is required and then renders the node with the required template using the renderTemplate(node, template) method.
Now, I don't want to hard code which template should be used in each scenario - I would like, in the content tabs, to list the scenarios and give the user the option of which template (choosing from the available templates for that node) to use for each scenario.
I'm not a .NET guy but I imagine that the control for picking the default template could be easily lifted and turned into a data type?
I know this is quite a complex system - I think I've considered all the other ways (eg. loads of nodes and then content pickers and XSLT which points to parent node properties - messy, especially as this structure would occur many times) but I could well be overlooking some simple functionality of Umbraco.
Thanks again for your help, it's much appreciated - this forum is great for discussion / answers about Umbraco.
Template Picker Datatype
I'd like to create a "template picker" datatype that works the same way the template combo box on every content node does - ie. a datatype that shows a list of all allowed templates for that type (document type) of node.
Is there an easy way to lift the combo box already there and turn it into a data type?
Hiya Edward I am not sure why you would want a Template Picker dataType? As surely you would just be duplicatiing functionality??
Warren
@warren, i understand exactly what you are saying, but it would be kinda nice if it could be moved to a 'content' tab instead of burried on the last tab [properties] i like to give clients the ability to use alternate templates, they often forget 'where to switch it' :P
I can understand you wanting to move it perhaps but duplicating it seems pointless.
In my opinion users just need good training/documentation on how to use their site - they will soon get to learn where to rename a node, unpublish it and set a different template style.
Warren :)
Maybe I'm missing something....
I would like, at run time, to decide which template to render.
So if a condition is true it renders template a and if its false it renders b. Instead of hard coding the template node ID I'd like to have a nice simple picker in the content section so if a is true it will render the template specified in the content section, or if b is true it will render another template specified in the content section.
Another example... A page is hit and XSLT detects the caller is an iPhone. Instead of sending a redirect back I would instead like to return the content rendered according to an iPhone template specified by the node in the content section. (NB this example is much simpler than my actual scenario but has the same concept).
I know I could stick everything in XSLT and just render appropriate bits but thats not a very modular solution.
Is there some functionality of alt templates that I'm missing? This must be possible....
You might want to look at the Tim's iPhone package
http://our.umbraco.org/projects/iphone-alt-page
Rich
Thanks Rich, but its not quite what I'm looking for.
The iPhone altTemplate package works by putting javascript at the top of each page that redirects the client to another page. This means the client downloads the normal content and then gets redirected by javascript (a simplification on my part, I know). What I want is to implement some logic in Umbraco for each request that decides which alternate template to render but I don't want to hard code the template IDs / aliases.
Also, as in my previous post, my motive isn't to create an iPhone template - this is just a simplified example of my concept.
Hiya Edward,
So if I understand you. Couldn't you jsut use XSLT with the altTemplate method of /templateAlias.aspx appened to the original node URL to switch to that view?
Warren
Sorry thinking about it again....
I still dont understand for the duplicate template picker.
If you want a node to have a certain template you just pick it from the dropdown and that particular ndoe will have that style of template from say the 5 different templates the type of node can have.
I am really missing the point.
Maybe you could explain in depth the scenario you are trying to achieve so I can understand your needs better.
Warren :)
Ok, I can't really elabourate on the exact details but here's the scenario:
1. I go to www.mysite.com/page
2. This page has, for example, 5 different templates and the template that is required isn't known until runtime.
3. My plan is to have one template (the default one) which calls some XSLT / control that implements the business logic of which template is required and then renders the node with the required template using the renderTemplate(node, template) method.
Now, I don't want to hard code which template should be used in each scenario - I would like, in the content tabs, to list the scenarios and give the user the option of which template (choosing from the available templates for that node) to use for each scenario.
I'm not a .NET guy but I imagine that the control for picking the default template could be easily lifted and turned into a data type?
I know this is quite a complex system - I think I've considered all the other ways (eg. loads of nodes and then content pickers and XSLT which points to parent node properties - messy, especially as this structure would occur many times) but I could well be overlooking some simple functionality of Umbraco.
Thanks again for your help, it's much appreciated - this forum is great for discussion / answers about Umbraco.
Maybe I can simplify this -
My question is:
Can I somehow simply copy the template picker drop down and turn it into a custom data type?
This would save me writing my own. I'm a .NET newbie so any help is much appreciated!
Just for those that stumble across this there is a package that may do this:
http://our.umbraco.org/projects/templatepicker
is working on a reply...