Copied to clipboard

Flag this post as spam?

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


  • Warren Buckley 2089 posts 4578 karma points MVP ∞ admin hq c-trib
    Mar 19, 2009 @ 13:46
    Warren Buckley
    0

    Testing against active template name? [SOLVED]

    Hello all I need to test against the current template that is being used by a page so I can apply some different logic to the page.

    But testing against @template only gives the template ID which will be different in DEV to the ID of the template in PRODUCTION.

    Is there anyway to test against the templateAlias instead?

    Thanks,
    Warren

  • Tim Geyssens 1060 posts 27 karma points
    Mar 19, 2009 @ 13:50
    Tim Geyssens
    0

    First thought:

    You could create an xslt extension that takes the template id and returns the template alias.

  • Warren Buckley 2089 posts 4578 karma points MVP ∞ admin hq c-trib
    Mar 19, 2009 @ 13:53
    Warren Buckley
    0

    Is that the only way to do it you think with an extension?

  • Dirk De Grave 4537 posts 6006 karma points MVP 3x admin c-trib
    Mar 19, 2009 @ 13:59
    Dirk De Grave
    0

    Or, use this in your template:

    <%= umbraco.cms.businesslogic.template.Template.GetByAlias("") %> and pass that as a param into macro that references the xslt.

    (Haven't done that yet, but would be surprised if that didn't work)

    Xslt extension would use the same code...

    Regards,
    /Dirk

  • Warren Buckley 2089 posts 4578 karma points MVP ∞ admin hq c-trib
    Mar 19, 2009 @ 14:03
    Warren Buckley
    0

    Thats wicked Dirk so does that return the int for that template alias?

  • Warren Buckley 2089 posts 4578 karma points MVP ∞ admin hq c-trib
    Mar 20, 2009 @ 15:54
    Warren Buckley
    1

    For anyone intrested this is how I SOLVED the problem with this XSLT Extension
    [code]
    ///


    /// Gets the current page templateAlias assigned to it
    ///

    /// Pass in the currentpage TemplateID
    ///
    public string GetTemplateAliasFromID(int templateID)
    {
    string templateAlias = string.Empty;
    Template umbracoTemplate = umbraco.cms.businesslogic.template.Template.GetTemplate(templateID);
    if (umbracoTemplate != null) templateAlias = umbracoTemplate.Alias;

    return templateAlias;
    }
    [/code]

  • Warren Buckley 2089 posts 4578 karma points MVP ∞ admin hq c-trib
    Mar 20, 2009 @ 16:17
    Warren Buckley
    0

    Here is an associated XSLT snippet as well.

    [code]



    [/code]

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies