More in this section

Forums / Developing with Sitefinity / Custom Image Gallery, Samples?

Custom Image Gallery, Samples?

6 posts, 0 answered
  1. Phill Hodgkinson
    Phill Hodgkinson avatar
    362 posts
    Registered:
    10 Nov 2004
    17 Feb 2010
    Link to this post
    Hi there,

    I'm looking to create a custom display mode for an image gallery. I have created the look I want using an external template and I can drop a built in image gallery and then change the TemplatePath to point to my new external template. That all works fine. However my goal is to create something that is easy to use for an end user updating the site. I'd like to either modify the existing Image Gallery or create a new one so that the step "2 - How to display the gallery?" only has the options that I want, ie. one of the build in views and then two of my own views. Is there an easy way to do this? Even better has anyone done this and have a sample project/code they can share? If this isn't possible, how about a simple control that doesn't used the Sitefinity Wizard, but just a "select a library" option and some other basic parameters.

    Any suggestions and/or feedback would be greatly appreciated.

    Cheers,
    Phill
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    17 Feb 2010
    Link to this post
    Hi Phill Hodgkinson,

    You can take a look at this post that explains how to work with presentation modes and ControlDesigners - Mapping ContentViewDesigners and working with Presentation Modes .

    If you plan to create a custom control you will need a control designer and implement the same logic for PresentationModes and TextSetting controls.

    Greetings,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. Phill Hodgkinson
    Phill Hodgkinson avatar
    362 posts
    Registered:
    10 Nov 2004
    19 Feb 2010
    Link to this post
    Hi Ivan,

    The article you sent helps a bit but doesn't solve my challenge If I want to add a new Mode, I get the following error:

    A required control was not found in the template for "~/CustomControls/Libraries/Admin/ImageGalleryControlDesigner.ascx". The control must be assignable form type "Telerik.Cms.Engine.WebControls.Design.PresentationModeSettings" and must have ID "ModeSettings6"


    If my only option is to Change MasterTemplateName to MasterTemplatePath and point to an external template, how can I update the small graphic icon in the ControlDesigner so that it represents what my custom presentation mode is going to look like? Is this possible?

    Also, not a show stopper but it's not a nice thing for the client (people, not software) is that in my UserControlTemplate I use Bind/Eval in a couple places. When in admin mode I get the message:
    "DataBinding Methods such as Eval(), XPath() and Bind() can only be used in controls contained in a page." Is there a way I can surpress this error? Ideally a preview of my template would be ideal but at the very least how would I go about hiding this and just having a "Preview not available in Edit Mode" message displayed?

    Many thanks in advance.
    Phill

  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    19 Feb 2010
    Link to this post
    Hi Phill Hodgkinson,

    1. The error is thrown because some of the required controls has been removed or cannot be found in your template. You need only to add the mode and it text settings as it is done with all other PresentationModes.

    It seems that you have missed to add

    <sfDesign:PresentationModeSettings ID="ModeSettings6" runat="server">
    </sfDesign:PresentationModeSettings>

    where you have to add your TextSettings

    2. You can show an image using css classes ( background : url(.../.../)) that are set over the designer generally set in
    ~/sitefinity/admin/Themes/Default/CtrlProp.css

    3. Databinding throws error because there is not page in edit mode. To skip the error you can do one of the following things

    •  use query string
    if (string.IsNullOrEmpty(HttpContext.Current.Request.QueryString["cmspagemode"]))
       {
          
       }


    • override InitializeControls or CreateChildControls and show custom label

    protected override void InitializeControls(Control controlContainer)
           {
               if (Page == null || DesignMode)
               {
                   Label nodesign = new Label();
                   nodesign .Text = "some text";
                   this.MyControl.Visible = false;
                   this.Controls.Add(nodesign);
               }
               else
               {
     
                  // your logic
               }
     }

    Greetings,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  5. Phill Hodgkinson
    Phill Hodgkinson avatar
    362 posts
    Registered:
    10 Nov 2004
    19 Feb 2010
    Link to this post
    Hi Ivan,

    As always Telerik/Sitefinity support is what really sets this CMS apart, thanks so much for your help! Items 1 and 2 addressed the issues I was having. However I'm still having an issue with item 3. When I do the check for (string.IsNullOrEmpty(HttpContext.Current.Request.QueryString["cmspagemode"])) it works when cmspagemode=preview (when the page is in a frame, but before you click "edit this page" button). My custom template is a UserControl and I've tried placing the check in Page_Load as well as override void Render, but when cmspagemode=edit it doesn't get fired and i'm not able to display a custom message. Any ideas what I might be missing?

    Thanks again!
    Phill
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    21 Feb 2010
    Link to this post
    Hi Phill Hodgkinson,

    You could try inheriting from ImageGalley and overriding CreateChildControls which should be called for sure.

    Kind regards,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Register for webinar
6 posts, 0 answered