/// <summary> /// Generates an href to the given asset that must live within the CMS. Sometimes a Platform Output specific ContentUrl call is more useful. /// </summary> /// <param name="assetPath"></param> /// <returns></returns> public string ContentUrl(string assetPath) { //mistakenly run through here... if (assetPath.StartsWith("//") || assetPath.StartsWith("http")) { return(assetPath); } string qs = null; int qsIndex; if ((qsIndex = assetPath.IndexOf("?")) > -1) { qs = assetPath.Substring(qsIndex); assetPath = assetPath.Substring(0, qsIndex); } if ((qsIndex = assetPath.IndexOf("#")) > -1) { qs = assetPath.Substring(qsIndex); assetPath = assetPath.Substring(0, qsIndex); } string returnPath = AssetPathResolver.ResolvePath(this.asset, assetPath); Asset target = Asset.Load(returnPath); if (qs != null) { return(target.GetLink(LinkType.Include) + qs); } else { return(target.GetLink(LinkType.Include)); } }
public string ContentUrl(string assetPath, LinkType linktype = LinkType.Default) { //mistakenly run through here... if(assetPath.StartsWith("//") || assetPath.StartsWith("http")) return assetPath; string qs = null; int qsIndex; if((qsIndex = assetPath.IndexOf("?")) > -1) { qs = assetPath.Substring(qsIndex); assetPath = assetPath.Substring(0, qsIndex); } if((qsIndex = assetPath.IndexOf("#")) > -1) { qs = assetPath.Substring(qsIndex); assetPath = assetPath.Substring(0, qsIndex); } if(PreserveCalls && context.IsPublishing) { string linktypeStr = GetLinkTypeCall(linktype); return string.Format("<$={0}.{1}(\"{2}\")$>{3}", Typename, linktypeStr, assetPath, qs); } else { string returnPath = AssetPathResolver.ResolvePath(this.asset, assetPath); Asset target = Asset.Load(returnPath); return target.GetLink(LinkType.Include) + qs; } }