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

Forums / Developing with Sitefinity / Extend Generic Content

Extend Generic Content

10 posts, 0 answered
  1. harlowhair
    harlowhair avatar
    12 posts
    Registered:
    21 Nov 2006
    29 Jun 2010
    Link to this post
    I have a site with a lot of content which is categorised, and currently generic content works well for this.  It displays a list of all items in the category and I can then click through and view the fulll item.  I would lke to add an image galerry to this however, so that when I click through and view the content I see it like the following:

    [Title]

    [Generic Content]

    [Image Gallery]

    Is it possible to extend the generic content module to allow this to be selected when it is created?
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    29 Jun 2010
    Link to this post
    Hello harlowhair,

    You need to create a custom control that inherits from ContentView and extend ContentItemEdit and ContentItemNew templates of Generic_Content module

    1.Map ContentItemEdit and ContentItemNew external template - How to map a template
    2. Add an additional metakey for ContentItemEdit and ContentItemNew external templates - UserManual page 219. You can implement a selector that will be used to pick up an Image/Document gallery  ID and save it as a metakey.

    3. Inside the custom ListPageDetail.ascx template for your ContentView control you need to add an ImageGallery or another control that will be more suitable for your design.
    4. Inside your custom control that inherits from ContentView you have to override SetSingleItemContent method. The method has one parameter - contentItem which you can use to get the custom metadata you have added by calling contentItem.GetMetaData. Then you can get your custom control added to the template from SingleContainer and pass the proper library ID.

    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
  3. harlowhair
    harlowhair avatar
    12 posts
    Registered:
    21 Nov 2006
    29 Jun 2010
    Link to this post
    Thanks Ivan.

    Once I have created the control, how is it integrated with the backend?  Currently I can manage the generic content by going to content in modules, which is where i have been creating my categorised content.
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    29 Jun 2010
    Link to this post
    Hello harlowhair,

    The control will be populated with data automatically, because you will inherit from ContentView. You need to register the control in your web.config

    sample

    <toolboxControls
        <clear />
    <add name="ContentViewCustomControl" section="Custom" type="ContentViewCustomControl, App_Code" />


    and use it instead of the default ContentView control when you want to show a gallery.

    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
  5. harlowhair
    harlowhair avatar
    12 posts
    Registered:
    21 Nov 2006
    07 Jul 2010
    Link to this post
    Hi Ivan,

    Thanks for the help, the process all makes sense however I am stuck on exactly what I need to enter in the configuration file to map the templates.  My new control is called ProjectProfileContentView, in the namespace CustomControls, how do I map the Edit and New templates?

    Thanks
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    07 Jul 2010
    Link to this post
    Hello harlowhair,

    Is this question for backend view or front end? The public controls that inherits from ContentView do not have edit and new template, these controls have only details and master templates. Once you override ItemListTemplatePath and SingleItemTemplatePath you should be able to set the public tempaltes

    sample code ( the templates path is set inside the code )

    public override string ItemListTemplatePath
        {
            get
            {
                return "~/Sitefinity/ControlTemplates/News/ListPageMaster.ascx";
            }
     
        }
     
        public override string SingleItemTemplatePath
        {
            get
            {
                return "~/Sitefinity/ControlTemplates/News/ListPageDetails.ascx";
            }
     
        }
     
     
        public override Type LocalizationAssemblyInfo
        {
            get
            {
                return this.GetType();
            }
            set
            {
                base.LocalizationAssemblyInfo = value;
            }
        }
     
        public override Type AssemblyInfo
        {
            get
            {
                return this.GetType();
            }
            set
            {
                base.AssemblyInfo = value;
            }
        }


    All the best,
    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
  7. harlowhair
    harlowhair avatar
    12 posts
    Registered:
    21 Nov 2006
    07 Jul 2010
    Link to this post
    This is for backend - I am trying to follow your guide as to how I can create a new content type which has an image gallery selector
  8. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    07 Jul 2010
    Link to this post
    Hello harlowhair,

    If this is for the backend view you have to override LayoutTemplatePath and LayoutTemplateName then you should be able to set the templates through your custom class or using ControlsConfig file by specifying your hostType

    <viewSettings hostType="Telerik.Samples.MyBackendView"
       layoutTemplatePath="~/Sitefinity/Admin/ControlTemplates/MyModule/MyBackendView.ascx" />


    Sincerely yours,
    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
  9. harlowhair
    harlowhair avatar
    12 posts
    Registered:
    21 Nov 2006
    07 Jul 2010
    Link to this post
    Ok, I think I am getting a bit confused here.  Initially my aim was to have a new content type added to the modules menu, called project profile, which worked exactly like Generic Content however had 1 additional field (an image gallery).  I think the steps you are describing will allow me to add the field to the actual Generic Content control, and then create a new ProjectProfileViewer control which will display the extra field.  Having had a better read through the manual I think that a Generic Content based module would achieve what I need.

    The one remaining question I have is around the ImageGallery selector control - is this an existing control or do I need to create one?

    Thanks
  10. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    07 Jul 2010
    Link to this post
    Hello harlowhair,

    There is a built in selector that you can use in case you want to select a single image

    [Browsable(true),
    DefaultValue(""),
    WebEditor("Telerik.Libraries.WebControls.ImageSelector, Telerik.Libraries")]
    public string File
    {
        get
        {
            if (ViewState["File"] != null)
            {
                return (string)ViewState["File"];
            }
            return "";
        }
        set
        {
            ViewState["File"] = value;
        }
    }

    There is no built in selector that you can use to pick up whole library. You need to create a custom selector that will allow you to select a whole library. I have provided sample code here. You can gather more information about custom selectors at creating_a_custom_webuitypeeditor

    You could also use ButtonSelector control which is used in NewsModule when you create or edit a content item.


    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
10 posts, 0 answered