Documentation > CMS Template API Library > Asset > CreateLibraryReference(String,Asset,Int32)

CreateLibraryReference

Create a reference in library with the given label in the given location.

public CrownPeak.CMSAPI.Asset CreateLibraryReference(String,Asset,Int32)


Returns

A newly created library reference.

Parameters

NameDescriptionType
label (Optional)The label to use. Default is "Reference to" added in front of the original library's name System.String
project The folder where the library is to be created. Must be a project CrownPeak.CMSAPI.Asset
externalLibraryId The id of the library that we are referencing. Must be in another project or the /System/Library System.Int32

Code Example

C#

Sample:
string label = "System Library";
Asset project = Asset.Load("/" + asset.AssetPath[0] + "/Project/");	
Asset extLibrary = Asset.Load("/System/Library/");

if(project.IsLoaded && extLibrary.IsLoaded)
{
  Asset newLibraryRef = Asset.CreateLibraryReference(label, project, extLibrary.Id);
  if(newLibraryRef.IsLoaded)
  {
    // Do Something
  }
}

Connect with Crownpeak