More in this section

Forums / Developing with Sitefinity / generic content template question

generic content template question

4 posts, 0 answered
  1. Mike Inman
    Mike Inman avatar
    2 posts
    Registered:
    09 May 2005
    07 May 2009
    Link to this post
    I am in the process of creating my own wrappers for some of the control templates so if, for example, a news view is added to the side bar then it will get a style that applies a background, rounded corners and a border using the divs I've added to the control template. The wrapper I'm creating is mainly needed for the rounded corners. I actually have this working with the NewsView and now I am trying to do the same for the "Generic Content" control template, but I can't seem to find a template that matches the html output for the generic content. Actually all that is rendered to the browser is simply whatever I entered into the RadEditor and nothing more, so I'm assuming I'm looking for a control template that has nothing more than a contentplaceholder control. The only control template that I've found that matches is the "HeaderLinks" template, but I'm pretty positive by the name that it's not the one I'm looking for. Am I just doing something wrong or can this not be done with the generic content control template? Any help is appreciated.
  2. Dido
    Dido avatar
    149 posts
    Registered:
    24 Sep 2012
    08 May 2009
    Link to this post
    Hello Mike Inman,

    GenericContent does not have template. It renders directly its content. GenericContent, however, has a control designer. It is called GenericContentDesigner. To override its template, you will need something like this in your ControlsConfig:

    <viewSettings 
       hostType="Telerik.Cms.Engine.WebControls.Design.GenericContentDesigner" 
       layoutTemplatePath="~/Sitefinity/Admin/ControlTemplates/Generic_Content/GenericContentDesigner.ascx"  
    /> 


    You might find this article helpful, as well.

    Kind regards,
    Dido
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. Mike Inman
    Mike Inman avatar
    2 posts
    Registered:
    09 May 2005
    10 May 2009
    Link to this post
    I don't really care about overriding the designer I just need to be able to put a wrapper around each generic content control on the page that a normal user would see when viewing the page. I don't understand why there isn't even just a simple control template with nothing more than a placeholder that could be overridden for situations like this. Is there any way that this can be done? Thanks.
  4. Dido
    Dido avatar
    149 posts
    Registered:
    24 Sep 2012
    11 May 2009
    Link to this post
    Hi Mike Inman,

    I can't think of any other way, but writing a new control. We recently upgraded the logic of GenericContentDesigner, so now you can do the same thing via a simple user control. Here is a sample on how to do this.

    Markup:
    <%@ Control Language="C#" AutoEventWireup="true" CodeFile="GCWrapper.ascx.cs" Inherits="User_Controls_GCWrapper" %> 
    <%@ Register Assembly="Telerik.Cms.Engine" Namespace="Telerik.Cms.Engine.WebControls"  TagPrefix="sfWeb" %> 
     
    <sfWeb:GenericContent runat="server" ID="GenericContent1" /> 

    Code-behind:
    using System; 
    using System.Collections.Generic; 
    using System.Linq; 
    using System.Web; 
    using System.Web.UI; 
    using System.Web.UI.WebControls; 
    using Telerik.Cms; 
    using System.ComponentModel; 
    using Telerik.Cms.Web.UI; 
    using Telerik.Framework.Web.Design; 
    using Telerik.Cms.Engine.WebControls; 
    using Telerik.Cms.Engine; 
    using Telerik.Web; 
     
    [ControlDesignerAttribute("Telerik.Cms.Engine.WebControls.Design.GenericContentDesigner, Telerik.Cms.Engine")] 
    public partial class User_Controls_GCWrapper : System.Web.UI.UserControl, IGenericContent   
        protected void Page_Load(object sender, EventArgs e) 
        { 
     
        } 
        #region IGenericContent Members 
     
        [CmsBrowsable(false)] 
        [CmsPersistable(true)] 
        public string Content 
        { 
            get 
            { 
                return GenericContent1.Content; 
            } 
            set 
            { 
                GenericContent1.Content = value; 
            } 
        } 
     
        [Browsable(false)] 
        public Guid ContentID 
        { 
            get 
            { 
                return GenericContent1.ContentID; 
            } 
            set 
            { 
                GenericContent1.ContentID = value; 
            } 
        } 
     
        public string ProviderName 
        { 
            get 
            { 
                return GenericContent1.ProviderName; 
            } 
            set 
            { 
                GenericContent1.ProviderName = value; 
            } 
        } 
     
        [Browsable(false)] 
        public IContent SharedContent 
        { 
            get 
            { 
                return this.GenericContent1.SharedContent; 
            } 
        } 
     
        public bool UseStagedVersion 
        { 
            get 
            { 
                return GenericContent1.UseStagedVersion; 
            } 
            set 
            { 
                GenericContent1.UseStagedVersion = value; 
            } 
        } 
     
        [CmsBrowsable(false), CmsPersistable(true)] 
        public bool HasDynamicLinks 
        { 
            get 
            { 
                return GenericContent1.HasDynamicLinks; 
            } 
            set 
            { 
                GenericContent1.HasDynamicLinks = value; 
            } 
        } 
     
        public string GetItemUrl(string provider, Guid id, bool resolveAsAbsoluteUrl) 
        { 
            return GenericContent1.GetItemUrl(provider, id, resolveAsAbsoluteUrl); 
        } 
     
        public void RenderBinaryContent(HtmlTextWriter writer) 
        { 
            GenericContent1.RenderBinaryContent(writer); 
        } 
     
        public void RenderTextContent(HtmlTextWriter writer) 
        { 
            GenericContent1.RenderTextContent(writer); 
        } 
        #endregion 
     

    Regards,
    Dido
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
Register for webinar
4 posts, 0 answered