DXM and Web Content Management
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

CMS Knowledge Base

Get Last Published Link

There are times where you may want to get the last published link instead of running the publish link again. However you also want to get the link if the asset has yet to be published.

 

This code will perform that function

 

public static string GetPublishedLink(Asset asset, OutputContext context = null, bool addDomain = false, ProtocolType protocolType = ProtocolType.Https, bool useLastCachedLink = false)
{
string outputLink = "";
if (asset.IsLoaded)
{
List<string> assetlinks = asset.GetLastPublishedLinks(addDomain, protocolType);
if (assetlinks.Count > 0)
{
if (useLastCachedLink)
{
outputLink = assetlinks[assetlinks.Count - 1];
}
else
{
outputLink = assetlinks[0];
} }
else
{
outputLink = asset.GetLink(addDomain, protocolType);
}
} return outputLink;
}
Labels (1)