...
If you require the generated IContent objects to have a different 'Parent' property than the default (which is the Digizuite Content Providers entry point), you can specify it in an optional parameter. This can be useful if you want the objects to be listed below a certain folder for example.
Figuring out which values to use for Crops, Sorting and Asset Types
When setting the above search parameters it's important to know which options is available to set. You can of course see this in your DAM Center's configuration, but that might not be available to the typical web site editor.
Luckily, whenever the Digizuite Client class (DFO 4.0.0 - 1 Understanding DAM For Optimizely) initializes, it connects to the DAM and retrieves lists of the various settings like Asset Types, Crop Names, Sorting methods and Media formats. They are then available in the "Configuration" object of the Client and can be called like myClient.Configuration.AssetTypes, myClient.Configuration.MediaFormats, myClient.Configuration.Crops, myClient.Configuration.SortFields.
Selection factories
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 in the Digizuite.Episerver.Helpers namespace, ready to use in attributes on properties like this:
...
See a full example further down!
...
The AssetQueryParameters has a Parse(string) method that can transform any string into an AssetQueryParameters object.
The parsing will check for the occurrence of key=value sets in the provided string and if the key is "crop" it will try to identify a crop name to filter on. If the key is "type" it will look for a single or a comma-separated list of asset types - either by their ID's or names.
If the key is "sort" it will try to identify a sort field from the value and set that. Any other key/value pairs will be added as OptionalFilters. Any additional text in the query that is not a key/value pair will be set as free text search.
If the entire query consists of a single number it will be treated as a request for a specific asset id.
Since this is exactly the same mechanism that is configured for the Digizuite Search Provider, you can actually try to search in the Digizuite Media tab and use this syntax!
Example: Building a Gallery Block
...
We will also make it optional which folders to search in, a Free text query, how many assets to show and so on. However, we won't worry about paging for now.
Code Block | ||
---|---|---|
| ||
[ContentType(DisplayName = "Gallery", GUID = "b05d16f0-877d-4784-8bf1-4a0ee2e57fd1", Description = "Shows a gallery of DAM assets")] public class GalleryBlock : BlockData { [CultureSpecific] [Display( Name = "Headline", Description = "Headline", GroupName = SystemTabNames.Content, Order = 1)] public virtual string Headline { get; set; } [Display( Name = "Max number of assets", Description = "", GroupName = SystemTabNames.Content, Description Order = 10)]"", public virtual int MaxNumberOfAssets {GroupName get; set; }= SystemTabNames.Content, [Display( Order = 10)] Name = "Asset Folders", Descriptionpublic =virtual "",int MaxNumberOfAssets { get; set; GroupName} = SystemTabNames.Content, Order = 20)] [UIHintDisplay(UIHint.AssetsFolder)] public virtual IList<ContentReference> Folders {Name get; set; } = "Free Text", [Display( NameDescription = "Free Text", Description = "", GroupName = SystemTabNames.Content, Order = 30)] public virtual string FreeText { get; set; } [Display( Name = "Crop Name", DescriptionName = "Folders", GroupName = SystemTabNames.Content, Order = 40)] [SelectOne(SelectionFactoryType Description = typeof(CropSelectionFactory))]"", public virtual string CropName {GroupName get; set; } [Display( Name = "Media Format", Description = "", GroupName = SystemTabNames.Content,= SystemTabNames.Content, Order = 40)] [SelectOneSelectMany(SelectionFactoryType = typeof(MediaFormatSelectionFactoryFoldersSelectionFactory))] public virtual string MediaFormatFolders { get; set; } public override void SetDefaultValues(ContentType contentType) { base.SetDefaultValues(contentType); this.MaxNumberOfAssets = 20; } } |
When we display this to the editors in edit-mode, this is what they'll see:
...