Created
February 19, 2014 21:13
-
-
Save fraabye/9101724 to your computer and use it in GitHub Desktop.
Simple Umbraco language switcher using the relations api
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @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> | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
useful, i just had to do this but only after seeing your look I think i've done it write