Documentation > CMS Template API Library > InputForm > GetPanelsFromFolder(Asset,String,AssetParams,AssetType,String,String)

GetPanelsFromFolder

Gets a List of AssetPanelEntry objects which bind panel data with Assets found in the folder provided. Panel data will be data in the inputform which has not yet been committed.

public List<AssetPanelEntry> GetPanelsFromFolder(Asset,String,AssetParams,AssetType,String,String)

Parameters

NameDescriptionType
folder The folder that contains the assets to bind to the panels CrownPeak.CMSAPI.Asset
panelName The panel name System.String
assetParams Optional: An AssetParams object that allows you to change how the list of bound assets is generated. CrownPeak.CMSAPI.AssetParams
type Optional: Allows you to specify a type of asset (files or folders) to return. By default, both are returned. CrownPeak.CMSAPI.AssetType
labelName Optional: The string that will be used to store the folder's label when we store the panel data. Use lower case. Defaults to panelName + ".label" System.String
idName Optional: The string that will be used to store the folder's id when we store the panel data. Use lower case. Defaults to panelName + ".id" System.String

Code Example

C#

Sample:

            
               List<AssetPanelEntry> panels = context.InputForm.GetPanelsFromFolder(asset.Parent, "folder_list", labelName: "folder_label", idName: "folder_id");
             
               foreach(AssetPanelEntry panel in panels)
               {
                 //Adding a new field called link so we don't ahve to check if it was an external or internal link in the output.
                 string link = "link_external";          
                 if ((panel["link_type"]).Equals("internal",StringComparison.OrdinalIgnoreCase))
                 {
                   link = "link_internal";
                 }
                 panel["page_link"] = panel[link];
               }
            
            

Connect with Crownpeak