More in this section

Forums / Developing with Sitefinity / Sitefinity apis, get images by category

Sitefinity apis, get images by category

2 posts, 0 answered
  1. Mohamed
    Mohamed avatar
    15 posts
    Registered:
    24 Oct 2010
    28 Jul 2011
    Link to this post
    Hello,

    I was wondering if it is applicable to categorize Image Albums ? Of not can I assign a cutsom meta field to an Album ?

    An also, how can I select images by category using the sitefinity apis ?

    Thanks,
  2. Boyan Barnev
    Boyan Barnev avatar
    1429 posts
    Registered:
    28 Aug 2017
    01 Aug 2011
    Link to this post
    Hello Mohamed,

    Currently the only way of adding a custom field to an Album is through code - you should use the TryCreateNew() method of the DynamicData facade - for instance:
    App.WorkWith().DynamicData().Type(typeof(PageData)).Field().TryCreateNew("MyPageDataField", typeof(string)).SaveChanges(true);
    where you should specify the proper data type for Albums. Once created the field can be accessed and modified using the GetValue() and SetValue() methods. An example of adding a custom field and accessing its values can be found on this forum thread. Please take a look at this article from our Documentation, I believe you might find it useful, concerning the second part of your question. Programmatically you can get the taxonomy using TypeDescriptior.GetProperties or DataExtension method - GetValue, for example:
    var myImages= App.WorkWith().Images()
    .Where(t => t.Status ==Telerik.Sitefinity.GenericContent.Model.ContentLifecycleStatus.Live)
    .Get()
    .ToList();
      
                foreach(var item in myImages)
                {
                    var summary = item.GetValue("Summary");
                }

    If you need any further information, please do not hesitate to let us know.

    Regards,
    Boyan Barnev
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
2 posts, 0 answered