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

Forums / Designing with Sitefinity / adding additional template to the news view control

adding additional template to the news view control

4 posts, 0 answered
  1. Zahid Ali
    Zahid Ali avatar
    47 posts
    Registered:
    16 Nov 2009
    08 Dec 2009
    Link to this post
    hi Guys,

    Is there a way I can add third template to the News View control.

    Currently, in the configuration.control.xml under app_data the news control as 2 view: ItemListTemplatePath & SingleItemTemplatePath.

    I want to be able add third one ItemListTemplateHomepagePath.

    I tried adding this key in the xml file, then added the ascx and resx file in the sitefinity/controltemplates/news folder but I can't seem to tie things together.

    Please advice.

    thanks.

    Zahid
  2. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    08 Dec 2009
    Link to this post
    Hi Zahid Ali,

    Unfortunately this is not an option with the default control. You can have another view, if you first override the control and this view to it. Then this view can be associated with the template, found under the path defined in the config file. 

    Regards,
    Georgi
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. Zahid Ali
    Zahid Ali avatar
    47 posts
    Registered:
    16 Nov 2009
    08 Dec 2009
    Link to this post
    thanks Georgi,

    Could I please request, if you could give me a list of steps involved in doing this or may point to the blog/guide outlining how this is done?

    thanks.

    Zahid
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    08 Dec 2009
    Link to this post
    Hi Zahid Ali,

     Here are the steps that you should follow.

    1. Create a custom control that inherits ContentView, ContentView based control or Simple Control.

    2. Create an enum with the desired view

    public enum ControlViews
          {
            View1,
            View2,
            View3
          }

    3. Create a private constraints for each view template

    private const string View1Template = "PATH TO YOUR TEMPLATE";
    private const string View2Template = "PATH TO YOUR TEMPLATE";
    private const string View3Template = "PATH TO YOUR TEMPLATE";

    4. Implement public property from where you set the desired presentation mode so that the correct templates is loaded

    5. Expose a public property for the template path of each view.


    public
    string View1
          {
              get
              {
                  object obj = ViewState["View1"];
                  if (obj != null)
                      return (string)obj;
                  return null;
              }
              set
              {
                  ViewState["View1"] = value;
              }
          }

    6. Override CreateChildControls() method and force the control to use your mode and template.

    7. Override SetListMetadata, SetSingleItemMetadata and if necessary ( depending on your particular requirements) implement a new method.

    Greetings,

    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Register for webinar
4 posts, 0 answered