Try Now
More in this section

Forums / Developing with Sitefinity / Shared content across templates except one page

Shared content across templates except one page

2 posts, 0 answered
  1. James@Nw
    James@Nw avatar
    265 posts
    05 May 2009
    14 Jun 2010
    Link to this post
    Hi Guys,

    Can you please tell me how I can exclude a shared content area on a particular page which has been shared across all pages? What's happened is that our client has asked us to add a line of text which is different from the rest of the other pages.

    Now, instead of having to remove the shared content from the template and now going to repeat that content across all the pages except for the one that is going to be different, I would like to EXCLUDE the template's shared content and show only THAT page's content.

    Does this make sense?

  2. Georgi
    Georgi avatar
    3583 posts
    28 Oct 2016
    14 Jun 2010
    Link to this post
    Hello James,

    Here is how you can find a shared Generic Content, together with the page reference:

    CmsManager manager = new CmsManager();
    // Get all GenericContent controls in a list
    IList pages = manager.GetPages();
    foreach (IPage page in pages)
        foreach (WebControl control in page.Controls)
            if (control.GetType() == (typeof(Telerik.Cms.Engine.WebControls.GenericContent)))
                Telerik.Cms.Engine.WebControls.GenericContent webControlGC = control as Telerik.Cms.Engine.WebControls.GenericContent;
                if (webControlGC != null)
                    //The Generic Content ID of the content showed in this control is:
                    Guid contentID = webControlGC.ContentID;
                    Response.Write(String.Format("We are on page {0}, and the content item is {1}<br />", page.Name, contentID));

    What is left is to check if this content id appears on all pages ( IList allPages = Manager.GetPages() )
    I hope this helps. 

    Kind regards,
    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.
2 posts, 0 answered