@Model.NodeById("Some static pageId").myVariable
To do this properly the Guid is needed instead. The problem though is that the Razor DynamicNode object doesn't expose or let you load nodes by the Guid. The included class can be added to your App_Code directory to allow the following code samples to work in Razor.
using JSP;
// Get a object by the Guid
@Model.NodeByGuid("someGuid").myVariable
// Print a object's Guid
@Model.UniqueId()
GuidExtensions.cs
using System;
using umbraco;
using umbraco.MacroEngines;
using umbraco.cms.businesslogic;
namespace JSP
{
/// <summary>
/// Extensions to the umbraco framework.
/// </summary>
public static class GuidExtensions
{
/// <summary>
/// Get a node by the unique Guid. This is needed for sites where courier is in use.
/// </summary>
/// <param name="self">Current Page</param>
/// <param name="guid">Guid to load.</param>
/// <returns>DynamicNode</returns>
public static DynamicNode NodeByGuid(this DynamicNode self, string guid)
{
return self.NodeByGuid(new Guid(guid));
}
/// <summary>
/// Get a node by the unique Guid. This is needed for sites where courier is in use.
/// </summary>
/// <param name="self">Current Page</param>
/// <param name="guid">Guid to load.</param>
/// <returns>DynamicNode</returns>
public static DynamicNode NodeByGuid(this DynamicNode self, Guid guid)
{
return self.NodeById(new CMSNode(guid).Id);
}
/// <summary>
/// Get the unique ID for a selected node.
/// </summary>
/// <param name="self">Node</param>
/// <returns>guid</returns>
public static string UniqueId(this DynamicNode self)
{
return new CMSNode(self.Id).UniqueId.ToString();
}
}
}