Copied to clipboard

Flag this post as spam?

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


  • JacoboPolavieja 62 posts 84 karma points
    Jul 01, 2010 @ 18:36
    JacoboPolavieja
    0

    Apply a template dynamically?

    Hello all!

     

    I have a site of news... which I would like to use different templates depending on the section of the web they are in each moment (a new might be a homepage new when it's published but then passed to a different section where it has a different design).

     

    I know how to create the templates and all, but... is there a way to apply it to the very same new depending of the situation?

     

    I have read this thread: http://our.umbraco.org/forum/templating/templates-and-document-types/8247-Template-alias-as-URL , but I don't know if that's really the topic treated.

     

    Any help? Thank you!

  • Rich Green 2246 posts 4008 karma points
    Jul 01, 2010 @ 18:44
    Rich Green
    0

    Yes, it's possible.

    The answer is in the link you've posted, you can do this using 'altTemplate'

    So for your current news article the URL maybe

    http://www.website.com/news/some-news.aspx

    When this news expires within your XSLT you would show it using a different template like this

    http://www.website.com/news/some-news.aspx?altTemplate=newsarchive

    Rich


  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Jul 01, 2010 @ 19:05
    Dirk De Grave
    0

    Or use the more seo friendly url for alternate template, in that case url would become

    http://www.website.com/news/some-news/newsarchive.aspx

     

    Cheers,

    /Dirk

  • JacoboPolavieja 62 posts 84 karma points
    Jul 01, 2010 @ 19:29
    JacoboPolavieja
    0

    Thanks for the answers and sorry to bother again...

     

    The thing is this goes within a masterpage. I mean... the masterpage could hold the "breaking news" section (which is a separate umbraco template) and the "not so breaking news" page (the same of above). Depending on which section the new is it should display it differently according to the section's template.

     

    If I did it that way, I wouldn't be needing to do anything more as long as the new support both section's templates... Am I right or even with that approach I would need to specify anything related to how to display the new?

     

    Thanks a lot... It's my first site with Umbraco and these are small quirks in the learning process... but all in all, I'm impressed at how good it's been built, really.

    Cheers!

  • Rich Green 2246 posts 4008 karma points
    Jul 01, 2010 @ 20:09
    Rich Green
    0

    You would need to put some logic in your XSLT file.

    So your master page would contain a macro that uses this XSLT file, when your XSLT file gets called it knows which section of the site it is being called from, therefore you can use this info combined with your logic to determine how to display the news.

    So in the XSLT file you would have logic like:

    - What section are we in?

    - If we are in section A,B or C then show news as "breaking news" 

    - else show news as "not so breaking news"

    Make sense?

    Rich

     

     

  • JacoboPolavieja 62 posts 84 karma points
    Jul 01, 2010 @ 20:33
    JacoboPolavieja
    0

    Aaaaal l the sense in the world Rich. Thanks for it.

     

    I guess XSLT macros are my next homework then... ;).

     

    Thank you! Cheers!

Please Sign in or register to post replies

Write your reply to:

Draft