Created
October 27, 2017 08:07
-
-
Save ps-team/42c5eb6bf00c3bc9939528bd37b9b0b9 to your computer and use it in GitHub Desktop.
Check if the content type is a hyperlink or not. Use FullPath if it is else use Path instead. Pass the content node to the function. Content types value set to 0, 16.
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
@using Contensis.Framework.Web | |
@{ | |
// Variables | |
var link = Properties.link; | |
<a href="@HyperlinkPath(link)">Link Text</a> | |
} | |
@functions { | |
// Check if its a hyperlink or not | |
public string HyperlinkPath(ContentNode property) { | |
if(!String.IsNullOrEmpty(property.ToString())){ | |
if(property.Type == "Hyperlink") { | |
return property.FullPath; | |
} else { | |
return property.Path; | |
} | |
} | |
return String.Empty; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment