Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

To make it even easier to use the values from the DAM Center in custom property drop down lists - for example in a block to hold a dynamic gallery, the integration also provides SelectionFactories for AssetType, Crops and MediaFormats SelectionFactory for folders in the Digizuite.Episerver.Helpers namespace, ready to use in attributes on properties like this: 

[SelectOneSelectMany(SelectionFactoryType = typeof(CropSelectionFactoryFoldersSelectionFactory))]
public virtual string CropName Folders { get; set; }

See a full example further down!

...

When we display this to the editors in edit-mode, this is what they'll see:

...

The folder selection can actually be dragged directly over from the Digizuite folder structure.We also have to have a standard controller that will popular a View Model with the assets to show. We do that here:

Code Block
languagec#
protected override IViewComponentResult InvokeComponent(GalleryBlock currentContent)
{
  GalleryBlockViewModel protectedgvm override= IViewComponentResultnew InvokeComponent(GalleryBlock currentContent)
        {GalleryBlockViewModel();
  gvm.CurrentBlock = currentContent;
  AssetQueryParameters aqm = new AssetQueryParameters();            
  aqm.Limit = currentContent.MaxNumberOfAssets;                     

  var facets = new List<FacetRequest>()
  {                   
GalleryBlockViewModel  gvm = new GalleryBlockViewModelFacetRequest();
    {
      FacetMode = gvm.CurrentBlock = currentContent;FacetMode.QueryOnly,
      Recursive = false,
      SearchKey = "assetType",
     AssetQueryParameters aqmValues = new AssetQueryParametersEnums.AssetType.Image.ToString().MakeIntList();
    }
  };

  if  aqm.FoldersToSearch = (!string.IsNullOrEmpty(currentContent.Folders ?? new List<ContentReference>();))
  {
    facets.Add(new FacetRequest()
    {
      FacetMode = aqm.Limit = currentContent.MaxNumberOfAssets;FacetMode.QueryOnly,
      Recursive = false,              aqm.Page = 1;    
      SearchKey  aqm.AssetTypes= _client.Configuration.FolderMetafieldGuid.ToString(),
      Values = GlobalConstantscurrentContent.AssetTypes.Image.MakeIntList();Folders.Split(",").ToList()                   
  aqm.CropName = currentContent.CropName});             aqm.OptionalFilters = new Dictionary<string,
string>();  }
  aqm.Facets = facets;
  
  if (!string.IsNullOrEmpty(currentContent.FreeText)) aqm.FreeText = currentContent.FreeText;
     
      gvm.Images = _client.Search(aqm.CacheFor(TimeSpan.FromMinutes(1)))?.Cast<IDigizuiteImage>()?.ToList();


         
  return View(gvm);
     
  }

Notice how we also make sure to set a cache timeout of 1 minute when doing the searching? That ensures a pretty updated image list, while not cause load to the DAM server for every page view. We could probably safely increase this number a lot. 

We also ensure that we will only search for images. AssetTypes.Image (from Digizuite.Episerver. Constants) is a constant int, set to the default Image Asset Type ID. The view is basically just about rendering the gallery, with the addition of rendering the images in the selected media format as described here: DFO 4.0.0 - 4 Referencing and Rendering Assets. Here is what the end result could look like:

...