Skip to content

Instantly share code, notes, and snippets.

@fraabye
Created February 19, 2014 21:13
Show Gist options
  • Save fraabye/9101724 to your computer and use it in GitHub Desktop.
Save fraabye/9101724 to your computer and use it in GitHub Desktop.
Simple Umbraco language switcher using the relations api
@inherits umbraco.MacroEngines.DynamicNodeContext
@using umbraco.cms.businesslogic.relation;
@{
RelationType relationType = RelationType.GetByAlias("relateDocumentOnCopy");
IEnumerable<Relation> relations = Relation.GetRelations(Model.Id , relationType);
var relation = relations.First();
int relationId = relations.First().Parent.Id;
if(relationId == Model.Id)
{
relationId = relation.Child.Id;
}
var relatedNode = Library.NodeById(relationId);
<a href="@relatedNode.Url" title="">@relatedNode.Name</a>
}
@johnseto
Copy link

useful, i just had to do this but only after seeing your look I think i've done it write

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment