Documentation > CMS Template API Library > Asset > GetProject(Asset)
GetProject
For a given asset find the project. If the asset is in a project or a child of a project that project will be returned. If the asset is a child of a site root, we will look for a project that is a child of a site root and that will be returned. If the asset is a child of a site root and does not have a child project, it will look for a sibling project to the site root and return that. If no project is found by either method, we will return an empty asset. If using a site root to find the project and more than one child or sibling is found which is a project, an error will be set and no project will be returned.
public CrownPeak.CMSAPI.Asset GetProject(Asset)
Returns
The project if found. If none is found returns an empty asset (IsLoaded will be false)
Parameters
Name | Description | Type |
---|---|---|
asset | The requested project asset. | CrownPeak.CMSAPI.Asset |
Code Example
C#
Asset projectFolder = Asset.GetProject(asset); Out.WriteLine(projectFolder.AssetPath.ToString());