Showing posts with label Umbraco. Show all posts
Showing posts with label Umbraco. Show all posts
Wednesday, 31 October 2012

Making Umbraco Courier publish on transfer

Add the following to your website's web.config file to have Umbraco Courier publish nodes automatically on transfer:
<configuration>
  <appSettings>
    <add key="CourierRepublish" value="true" />
  </appSettings>
</configuration>
This is particularly useful when nodes are being transferred from a production environment to a test environment as the content does not need to be reviewed before it is published.
Saturday, 4 August 2012

Using razor within an Umbraco template

Normally you restrict use of razor to the scripting folder in the developer tab and expose them via macros, but you can also use them inside a template by creating an inline macro like so:
<umbraco:Macro runat="server" Language="razor">
@{
    // insert razor here
    var href = "index.htm";
    <a href="@href">Home</a> 
} 
</umbraco:Macro>
This should only be done for small one-offs where you are unlikely to need to reuse the functionality, such as loading in the page title. Keep anything greater than that in the scripting folder.
Tuesday, 24 July 2012

ASP.NET MVC inline functions in a razor view

Here is the syntax for defining inline functions in an ASP.NET MVC razor view. I found this particularly useful when working with Umbraco as the regular alternatives like extension methods and helper classes aren't available.
@functions
{
    HtmlString PrintSomething()
    {
        return new HtmlString("Hello World");
    }
}
Returning a HtmlString object will allow you to print to the screen.
<div>@PrintSomething()</div>