Dynamic folders with copying script
Posted: Sun Mar 04, 2012 8:38 pm
				
				This example demonstrates the ability to create dynamic folders and copying script to properties of child folders for creating further levels of navigation. 
The folder Collections - right click - Add folder
Title: Realtime folders
Type: Dynamic (script)
click Script
Expression
Ok - Ok
			The folder Collections - right click - Add folder
Title: Realtime folders
Type: Dynamic (script)
click Script
Expression
Code: Select all
const
  mpiFolderType         = 200;  
  mpiDynamicScript      = 500;
  mpiDynamicSyntaxType  = 501;  
function ItemLevel(aItem: TWmsScriptMediaItem): Integer;
begin
  Result := -1;
  while aItem <> nil do begin
    aItem := aItem.ItemParent;
    Inc(Result)
  end    
end;
var
  ChildFolder: TWmsScriptMediaItem;  
  i: Integer;
begin
//  WmsLogMessage(mtiInfo, FolderItem.Properties[mpiTitle]);
  if ItemLevel(FolderItem) < 10 then begin
    for i := 1 to 5 do begin
      ChildFolder := FolderItem.AddFolder(FolderItem.Properties[mpiTitle] + '_' + IntToStr(i));
      if ChildFolder <> nil then begin    
        ChildFolder.Properties[mpiFolderType] := FolderItem.Properties[mpiFolderType];        
        ChildFolder.Properties[mpiDynamicScript] := FolderItem.Properties[mpiDynamicScript];
        ChildFolder.Properties[mpiDynamicSyntaxType] := FolderItem.Properties[mpiDynamicSyntaxType];        
      end
    end    
  end else  
    for i := 1 to 5 do         
      WmsCreateMediaItem(FolderItem.Properties[mpiTitle] + '_Item_' + IntToStr(i), FolderItem.ItemID);
end.