More in this section

Forums / Developing with Sitefinity / Use one GContent as template for List or DetailNews

Use one GContent as template for List or DetailNews

5 posts, 0 answered
  1. Pierre
    Pierre avatar
    433 posts
    Registered:
    16 Feb 2006
    07 Nov 2009
    Link to this post
    Hi,

    Exist some way to use one generic content as template for List or Detail News or insert in the repeater as headertemplate. I searching to build one List of News that have one Shared Generic Content that wrapping the content using complex header and closing tags.It´s obvious that you can add one manually after and before but is not secured solution. To make that one solution is create one custom View that use one shared content (very complex) as template or using one Generic content as template for the news.

    <asp:Repeater ID="repeater" runat="server"
        <HeaderTemplate> 
             //HERE ONE SHARED GENERIC CONTENT THAT WRAPP  
        </HeaderTemplate> 
        <ItemTemplate> 
             // NORMAL NEWS CONTENT 
        </ItemTemplate> 
        <FooterTemplate> 
            //HERE THE CLOSING WRAPP     
        </FooterTemplate> 
    </asp:Repeater> 

    Thanks for your suggestions.
    Romi.
  2. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    09 Nov 2009
    Link to this post
    Hello Pierre,

    This is possible in the following way:

    1. Register the Generic Content control assembly in the user control template, and define the control itself:
    <%@ Register Assembly="Telerik.Cms.Engine" Namespace="Telerik.Cms.Engine.WebControls" TagPrefix="gc" %>
     
    <gc:GenericContent id="footer" runat="server" ProviderName="Generic_Content" />

    In the code behind of the template, reference the control and set the ContentID guid of the Generic Content item that should be shown:

    protected void Page_Load(object sender, EventArgs e)
    {
        footer.ContentID = //GUID of the content item that you will use as footer
    }

    All the best,
    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. Pierre
    Pierre avatar
    433 posts
    Registered:
    16 Feb 2006
    09 Nov 2009
    Link to this post
    I have tried implementing IGenericContect interface in one derived contentView class and added one WebEditor but have some problems to cast the GenericControl inside the Template and how to use from one external designer using the hyperlink to shared content as properties for the designer.
     
    <asp:Repeater ID="repeater" runat="server">
        <HeaderTemplate>
                <sfWeb:GenericContent runat="server" ID="GenericContent1" />
        </HeaderTemplate>

    my ContentView
        protected virtual GenericContent GenericContent1
            {
                get { return base.ListContainer.GetControl<GenericContent>("GenericContent1", true); }
            }

    Some suggestions?
    Regards

  4. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    09 Nov 2009
    Link to this post
    Hi Pierre,

    Unfortunately I am not sure what you mean by the second post. Can you please elaborate?

    All the best,
    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.
  5. Pierre
    Pierre avatar
    433 posts
    Registered:
    16 Feb 2006
    09 Nov 2009
    Link to this post
    Hi,

    Sorry. I use one ContentView class implementing one Designer. I searching to link the generic contents using the designer and passing to the ContentView to use in the MasterList Template as header or footer like other samples.

    class
    [ToolboxData("<{0}:ModalView runat=\"server\"></{0}:ModalView>")] 
        [ControlDesigner("Web.UI.Public.ModalUIListDesigner")] 
        public class MyModalView : ContentView, IGenericContent 
        { 

    Cast the generic content from template to use in ContentView --> NOT FIRE the template
     protected virtual GenericContent GenericContent1 
            { 
                get { return base.ListContainer.GetControl<GenericContent>("GenericContent1", true); } 
            } 

    IGenericContent interface in ContentView
            #region IGenericContent Members 
             
            Added as Propertie for GCModule 
            [Category("Generic Content Top")] 
            [DisplayName("Content")] 
            [CmsPersistable(true)] 
            [Telerik.Cms.Web.UI.WebEditor("Telerik.Cms.Engine.WebControls.HtmlContentEditor, Telerik.Cms.Engine")] 
            [TypeConverter(typeof(StringConverter))] 
            public string Content 
            { 
                get 
                { 
                    return GenericContent1.Content; 
                } 
                set 
                { 
                    GenericContent1.Content = value
                } 
            }   
             
            [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 GenericProviderName 
            { 
                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   

    During the firts steps the Cast of GenericContent registred control in the Template is not working. May be need to cast some internal item ?
    Whats is the best way to pass the shared content from designer to the ContentView?
Register for webinar
5 posts, 0 answered