Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Edward Dudley 80 posts 121 karma points
    Nov 11, 2009 @ 18:02
    Edward Dudley
    0

    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?

  • Warren Buckley 2106 posts 4836 karma points MVP ∞ admin hq c-trib
    Nov 11, 2009 @ 21:24
    Warren Buckley
    0

    Hiya Edward I am not sure why you would want a Template Picker dataType? As surely you would just be duplicatiing functionality??

    Warren

  • bob baty-barr 1180 posts 1294 karma points MVP
    Nov 11, 2009 @ 21:40
    bob baty-barr
    0

    @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

  • Warren Buckley 2106 posts 4836 karma points MVP ∞ admin hq c-trib
    Nov 12, 2009 @ 09:11
    Warren Buckley
    0

    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 :)

  • Edward Dudley 80 posts 121 karma points
    Nov 12, 2009 @ 11:22
    Edward Dudley
    0

    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....

  • Rich Green 2246 posts 4008 karma points
    Nov 12, 2009 @ 11:52
    Rich Green
    0

    You might want to look at the Tim's iPhone package

    http://our.umbraco.org/projects/iphone-alt-page

    Rich

     

  • Edward Dudley 80 posts 121 karma points
    Nov 12, 2009 @ 14:33
    Edward Dudley
    0

    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.

  • Warren Buckley 2106 posts 4836 karma points MVP ∞ admin hq c-trib
    Nov 12, 2009 @ 17:01
    Warren Buckley
    0

    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

  • Warren Buckley 2106 posts 4836 karma points MVP ∞ admin hq c-trib
    Nov 12, 2009 @ 17:03
    Warren Buckley
    0

    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 :)

  • Edward Dudley 80 posts 121 karma points
    Nov 13, 2009 @ 08:16
    Edward Dudley
    0

    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.

  • Edward Dudley 80 posts 121 karma points
    Nov 19, 2009 @ 11:33
    Edward Dudley
    0

    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!

  • Jason Prothero 422 posts 1243 karma points c-trib
    Jan 19, 2011 @ 19:35
    Jason Prothero
    2

    Just for those that stumble across this there is a package that may do this:

     

    http://our.umbraco.org/projects/templatepicker

Please Sign in or register to post replies

Write your reply to:

Draft