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

Forums / General Discussions / Single Generic Content item widget

Single Generic Content item widget

13 posts, 0 answered
  1. Neil Mercer
    Neil Mercer avatar
    10 posts
    Registered:
    24 Sep 2009
    05 Nov 2010
    Link to this post
    Hi,

    Is it possible to configure the standard Generic Content List widget to display a single generic content item in detail view?  Or would I have to create my own widget for this?

    Alternatively, I'm trying to create some content (a list) that can be added to any page, but updated centrally.  A generic content item seemed perfect for this, but if there's a better idea please let me know.

    Thanks,
    Neil.
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    05 Nov 2010
    Link to this post
    Hello Neil,

    There is a way to do this, but you should override CreateChildControls method of ContentView control.

    protected override void CreateChildControls()
        {
            this.Controls.Clear();
            ResolveDetailItem();
            var currentView = this.DetermineCurrentViewName();
            var manager = NewsManager.GetManager();
            var itm = manager.GetItem(typeof(NewsItem), new Guid("a2f41c08-2d37-45db-8a9d-bbfdb5076dce"));
            var c = itm as IContent;
            this.DetailItem = c;
            this.LoadView(currentView);
        }


    Best wishes,
    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. Damian
    Damian avatar
    27 posts
    Registered:
    01 Dec 2010
    14 Dec 2010
    Link to this post
    Where do you put this code?
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    14 Dec 2010
    Link to this post
    Hi Damian,

    Create a custom class library and inherit from ContentView. Then you need to register the control from Sitefinity >>Administration >>Settings >> Toolboxes

    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. Damian
    Damian avatar
    27 posts
    Registered:
    01 Dec 2010
    14 Dec 2010
    Link to this post
    Thanks! That worked.

    A follow up question: Is there a way to let the admin users pick a generic content to display in this control without hardcoding a guid in the control itself?  Maybe have a generic content picker or let users find out the guid of their generic content and paste it into some kind of property on this widget?
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    14 Dec 2010
    Link to this post
    Hi Damian,

    You can expose a public property of your custom control or some kind of ControlDesigner.

    Best wishes,
    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. Damian
    Damian avatar
    27 posts
    Registered:
    01 Dec 2010
    14 Dec 2010
    Link to this post
    Thanks again! The public property works great. 

    Is there any way to hide the inherited properties like AccessKey, BackColor, etc so that admin users wouldn't care about when editing a widget?
  8. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    14 Dec 2010
    Link to this post
    Hi Damian,

    Override the properties and add [Browsable(false)]  attribute to them.

    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
  9. Damian
    Damian avatar
    27 posts
    Registered:
    01 Dec 2010
    14 Dec 2010
    Link to this post
    Perfect.  Thanks so much!
  10. Neil Mercer
    Neil Mercer avatar
    10 posts
    Registered:
    24 Sep 2009
    14 Dec 2010
    Link to this post
    Hi Damian,

    I never got round to solving this myself - any chance you can share the source for your widget?

    Cheers,
    Neil.
  11. Damian
    Damian avatar
    27 posts
    Registered:
    01 Dec 2010
    14 Dec 2010
    Link to this post
    My code looks something like this:

    01.using System;
    02.using System.Collections.Generic;
    03.using System.Linq;
    04.  
    05.namespace SitefinityWebApp.Classes
    06.{
    07.    public class GenericContentItem : System.Web.UI.WebControls.CompositeControl, Telerik.Sitefinity.Web.UI.ICustomWidgetVisualization
    08.    {
    09.        public string ContentTitle { get; set; }
    10.  
    11.        protected override void CreateChildControls()
    12.        {
    13.            if (ContentTitle == null)
    14.                return;
    15.  
    16.            var manager = new Telerik.Sitefinity.Modules.GenericContent.ContentManager();
    17.            var content = manager.GetContent().ToList().FirstOrDefault(item => item.Title.Value.ToLower() == this.ContentTitle.ToLower());
    18.  
    19.            if (content != null)
    20.                this.Controls.Add(new System.Web.UI.LiteralControl(content.Content.Value));
    21.        }
    22.  
    23.        #region ICustomWidgetVisualization Members
    24.        string Telerik.Sitefinity.Web.UI.ICustomWidgetVisualization.EmptyLinkText { get { return string.Empty; } }
    25.        bool Telerik.Sitefinity.Web.UI.ICustomWidgetVisualization.IsEmpty { get { return false; } }
    26.        #endregion
    27.    }
    28.}
  12. Pavol Kokinda
    Pavol Kokinda avatar
    39 posts
    Registered:
    28 Sep 2012
    08 Mar 2011
    Link to this post
    Hi Telerik,

    so longer I work with Sitefinity 4, I can not shake the feeling that this is an unfinished version. How do I explain my customer that they can not work with this version because some things like generic content not work as that are accustomed from version 3.7 where they were right? The customer does not need a list of generic content, but a simple sharing of a single generic content items. Customer paid for a product that is not functioning as it should be and was before and now have to pay the work that I do make it working as before? Really frustrated! This way I can forget about the other contracts !!!

    Greatings,

    Pavol Kokinda
  13. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    08 Mar 2011
    Link to this post
    Hello Pavol,

    Shared content will be available for Q1 release. Please check our roadmap to see all other new features that we will have.

    Best wishes,
    Ivan Dimitrov
    the Telerik team
13 posts, 0 answered