Copied to clipboard

Flag this post as spam?

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


  • Vincent Ashby-Smith 67 posts 196 karma points
    Jan 20, 2010 @ 18:06
    Vincent Ashby-Smith
    0

    If statments in templates

    Is it possible to have if statments in a template, so if the value of checkbox is checked do something? Can you do some kind of inline xslt?

  • Seth Niemuth 275 posts 397 karma points
    Jan 20, 2010 @ 18:18
    Seth Niemuth
    0

    You can use inline xslt:

    http://umbraco.org/documentation/books/inline-xslt

    but I dont know about using an if statement.

    You would probably just want to either create a macro (that uses XSLT) or use javascript.

  • Warren Buckley 2106 posts 4836 karma points MVP 7x admin c-trib
    Jan 20, 2010 @ 18:34
    Warren Buckley
    0

    Hiya Vincent you could do the following:

    As templates are .NET masterpages you could drop in an asp:checkboxlist control directly onto the masterpage and create a codebehind file in Visual studio to do your code

    OR the best practise & common way is to have any dynamic functionality (such as forms etc) put into a ASP.NET usercontrol.

    To add a .NET usercontrol to your template you need to:

    • Add the usercontrol .ascx file in the /usercontrols folder
    • Copy the compiled code (.dll) to the /bin directory
    • Login to Umbraco and goto the Developer section
    • Right click on the macro folder and click create/new
    • Give your macro a meaningful name - eg contactform
    • On the macro use the dropdown next to .net usercontrol and browse to your .ascx file
    • Ammend the alias to suit your coding style (camelCase) or whatever
    • Hit Save
    • Goto your template/masterpage you wish to add the macro to in Umbraco
    • Then click the fourth icon from the left (has this as the icon ><)
    • Choose which macro you wish to insert into the template
    • Save the template & volia you have your .NET usercontrol running in your template

    I hope this helps you out.
    Warren :)

     

  • 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