+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Images and Documents documents Command Panel

Images and Documents documents Command Panel

7 posts, 3 answered
  1. Fernando
    Fernando avatar
    31 posts
    Registered:
    08 Jun 2009
    18 Apr 2011
    Link to this post
    Hi,
    I've created a view for the Images and Documents module, but I couldn't make the link for the view be displayed in the Command Panel.

    I followed this post:
    http://www.sitefinity.com/blogs/ivan/posts/09-02-24/adding_child_views_to_the_view.aspx

    But nothing happened on the command panel when I added the view to the Controls Config file. When I type the URL setting the route I can see the view working fine. The problem is just the link in the command panel.
    This is what I used in the controls config:

    <viewSettings hostType="Telerik.Libraries.WebControls.Admin.LibrariesControlPanel">
         <views>
             <add name="LibraryView"
                  virtualPath="~/UserControls/Custom/LibrariesView.ascx"
                  title="Libraries View"
                  description="Libraries View." />
        </views>
    </viewSettings>


    I also tried to use an external template, but when I set the external template for "Telerik.Libraries.WebControls.Admin.LibrariesCommandPanel", it doesn't change anything, the control specified in the Layout Template PAth is not used.

    Is there something different to do to replace/extend the Images and Documents Command Panel?


    Fernando Melo
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    18 Apr 2011
    Link to this post
    Hi Fernando,

    There is a bug that does not allow you to add custom view to this module. The fix will require to override CreateStandardCommandPanels and implement a method where you inject your command.

    protected override void CreateStandardCommandPanels(string viewMode, List<CommandItem> commandsInfo, List<Telerik.Web.ICommandPanel> list)
          {
     
                      if (this.ParentId != Guid.Empty)
                      {
                          this.CreateItemsCommands(list);
                      }
                      else
                      {
                          base.CreateLibrariesCommands(list);
                      }
      
          }


    private void CreateItemsCommands(List<Telerik.Web.ICommandPanel> list)
          {
              Cms.Web.UI.Backend.CommandPanel helperCommandPanel = new Cms.Web.UI.Backend.CommandPanel();
              helperCommandPanel.AddCommand("", "LibrariesControlPanel.LibrariesView.LibraryList`1", null, null, Messages.AllLibraries, String.Empty, "backWrapp");
              list.Add(helperCommandPanel);
     
              Cms.Web.UI.Backend.CommandPanel itemsCommandPanel = new Cms.Web.UI.Backend.CommandPanel();
              itemsCommandPanel.Title = Messages.ExploreLibrary;
              string itemsText = Messages.Items;
              ILibrary library = this.LibManager.GetLibrary(this.ParentId);
              if (library != null)
              {
                  switch (library.TypeName)
                  {
                      case LibraryInfo.Library_Image_Name:
                          itemsText = Messages.Images;
                          break;
                      case LibraryInfo.Library_Document_Name:
                          itemsText = Messages.Documents;
                          break;
                      case LibraryInfo.Library_Video_Name:
                          itemsText = Messages.Movies;
                          break;
                      default:
                          itemsText = Messages.Items;
                          break;
                  }
              }
             
              foreach (var viewInfo in this.Views.Values)
              {
    if (viewInfo.ViewName == "LibraryView")
                  {
                      itemsCommandPanel.AddCommand("LibraryView", ControlUtils.SliceRoute(GetControlPanelRoute(), this.Name), null, this.ParentId.ToString(), null, itemsText, Messages.ItemsDescription, "all");
                      continue;
                  }


                  if (viewInfo.ViewName == "TagsView")
                  {
                      itemsCommandPanel.AddCommand("TagsView", ControlUtils.SliceRoute(GetControlPanelRoute(), this.Name), null, this.ParentId.ToString(), null, viewInfo.Title, Messages.TagsDescription, "all");
                      continue;
                  }
                  if (viewInfo.ViewName == "LibraryItemsView")
                  {
                      itemsCommandPanel.AddCommand("LibraryItemsView", ControlUtils.SliceRoute(GetControlPanelRoute(), this.Name), null, this.ParentId.ToString(), null, itemsText, Messages.ItemsDescription, "all");
                      continue;
                  }

     
                  if (viewInfo.ViewName == "CategoriesView")
                  {
                      itemsCommandPanel.AddCommand("CategoriesView", ControlUtils.SliceRoute(GetControlPanelRoute(), this.Name), null, this.ParentId.ToString(), null, viewInfo.Title, Messages.CategoriesDescription, "all");
                      continue;
                  }
              }
     
              if (library != null && (library.TypeName == LibraryInfo.Library_Video_Name || library.TypeName == LibraryInfo.Library_Viddler_Name))
              {
                  itemsCommandPanel.AddCommand("LibraryCommentsView", ControlUtils.SliceRoute(GetControlPanelRoute(), this.Name), null, this.ParentId.ToString(), null, Messages.Comments, Messages.CommentsDescription, "all");
              }
              /// add the viddler synchronizer.
              if (library != null && library.TypeName == LibraryInfo.Library_Viddler_Name)
              {
                  itemsCommandPanel.AddCommand("ViddlerSynchronizerView", ControlUtils.SliceRoute(GetControlPanelRoute(), this.Name), null, this.ParentId.ToString(), null, Messages.VideoSynchronizer, Messages.VideoSynchronizer_Desc, "all");
              }
     
              list.Add(itemsCommandPanel);
     
              Cms.Web.UI.Backend.CommandPanel settingsCommandPanel = new Cms.Web.UI.Backend.CommandPanel();
              settingsCommandPanel.Title = Messages.SetDetails;
              if (this.ParentId != Guid.Empty)
              {
                  if (this.LibManager.GetPermission(CrudRights.Modify).CheckDemand() ||
                     library.Owner.Equals(SecurityManager.GetCurrentUserName(),
                                          StringComparison.OrdinalIgnoreCase))
                  {
                      settingsCommandPanel.AddCommand("LibraryEdit`1", "LibrariesControlPanel.LibrariesView", null, this.ParentId.ToString(), Messages.SetDetails, String.Empty, "settings");
                  }
              }
              settingsCommandPanel.AddCommand("PermissionsView", ControlUtils.SliceRoute(GetControlPanelRoute(), this.Name), null, this.ParentId.ToString(), null, Messages.Permissions, String.Empty, "globalPerm");
              list.Add(settingsCommandPanel);
          }

    Then you have to create a custom class that inherits from LibrariesModule and override CreateControlPanel
    where you return your custom control panel

    public override Control CreateControlPanel(TemplateControl parent)
        {
            return new Telerik.Libraries.WebControls.Admin.LibrariesControlPanelCustom(false);
        }


    Regards,
    Ivan Dimitrov
    the Telerik team

    Answered
  3. Fernando
    Fernando avatar
    31 posts
    Registered:
    08 Jun 2009
    19 Apr 2011
    Link to this post
    But which class do I have to inherit to override CreateStandardCommandPanels?
    I tried Telerik.Libraries.WebControls.Admin.LibrariesControlPanel but this one doesn't have a method called CreateLibrariesCommands, that is called in the else statement in your CreateStandardCommandPanels.

    Fernando Melo
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    20 Apr 2011
    Link to this post
    Hello Fernando,

    If you inherit the LibrariesControlPanel and you use Sitefinity SP4 you should be able to override this method.

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using Telerik.Libraries.WebControls.Admin;

    /// <summary>
    /// Summary description for Lcp
    /// </summary>
    public class Lcp : LibrariesControlPanel
    {
        public Lcp()
        {
     
        }

        protected override void CreateStandardCommandPanels(string viewMode, List<Telerik.Cms.Web.UI.Backend.CommandItem> commandsInfo, List<Telerik.Web.ICommandPanel> list)
        {
            //base.CreateStandardCommandPanels(viewMode, commandsInfo, list);
        }
    }


    All the best,
    Ivan Dimitrov
    the Telerik team

    Answered
  5. Fernando
    Fernando avatar
    31 posts
    Registered:
    08 Jun 2009
    26 Apr 2011
    Link to this post
    I am able to override. I just can't use that code, with the method CreateLibrariesCommands:

    protected override void CreateStandardCommandPanels(string viewMode, List<CommandItem> commandsInfo, List<Telerik.Web.ICommandPanel> list)
    {
        if (this.ParentId != Guid.Empty)
            this.CreateItemsCommands(list);
        else
            base.CreateLibrariesCommands(list); //there is no CreateLibrariesCommands in the base class, even on SP4
    }

    should I use this instead?

    protected override void CreateStandardCommandPanels(string viewMode, List<Telerik.Cms.Web.UI.Backend.CommandItem> commandsInfo, List<Telerik.Web.ICommandPanel> list)
    {
       //should it be commented?
       //base.CreateStandardCommandPanels(viewMode, commandsInfo, list);
    }


    If I use the second code, with or without comment bars, I have other problems.
    The class Message, where does that comes from?

    I tried using this, but no one worked:

    using Telerik.Rss.Resources;
    using Telerik.Lists.Resources;
    using Telerik.Testimonials.Resources;
    using Telerik.Libraries.Data.Resources;
    using Telerik.Notifications.Data.Resources;

    and the method GetControlPanelRoute()? Do I have to create it?

    Fernando Melo

  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    28 Apr 2011
    Link to this post
    Hello Fernando,

    Messages gets embedded resource, you can put some string there.

    GetControlPanelRoute


    private List<string> GetControlPanelRoute()
            {
                List<string> controlPanelRoute = ControlUtils.ParseRoute(ControlUtils.GetCurrentRoute());
                if (controlPanelRoute.Count == 0)
                    controlPanelRoute.Add(this.Name);
                return controlPanelRoute;
            }


    All the best,
    Ivan Dimitrov
    the Telerik team

    Answered
  7. Fernando
    Fernando avatar
    31 posts
    Registered:
    08 Jun 2009
    28 Apr 2011
    Link to this post
    Thank you very much!


    Fernando Melo
Register for webinar
7 posts, 3 answered