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

Forums / Developing with Sitefinity / Displaying References to Shared Content

Displaying References to Shared Content

2 posts, 0 answered
  1. Chris Dodge
    Chris Dodge avatar
    16 posts
    Registered:
    17 Dec 2009
    13 May 2010
    Link to this post
    Hello,

    Our editors would like some means to know which pages reference a given piece of shared content. They'd like to be able to QA any edits to shared content before publishing.

    Is there any native support for this feature in Sitefinity 3.7 SP3? If not, I'd consider writing a custom admin page to do this. Is there a way programmatically to get such a list?

    Thanks,

    Chris Dodge
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    13 May 2010
    Link to this post
    Hi Chris Dodge,

    There is no built in option that you could use to see on which page you have a shared generic content. On a page you have controls which are bound to a datasource. If you use GenericContent control than you could easily loop through all pages and controls collection and look for control of type GenericContent. If there is such control you could check its SharedContent property.

    sample code

    var cmsManager = new CmsManager();
            // loop through all pages use cmsManager.GetPages();
            var cmp = (ICmsPage)cmsManager.GetPage(new Guid("3b6288fb-4a8d-4a99-85ed-c7f7b4098c7b"));
            if (cmp != null)
            {
                foreach (ICmsWebControl c in cmp.Staged.Controls)
                {
                    if (c.ControlType == typeof(Telerik.Cms.Engine.WebControls.GenericContent))
                    {
                        var gcControl = c.LoadControl() as GenericContent;
                        if (gcControl.SharedContent != null)
                        {
                           // you have shared content in this page
                           // you could get/set some properties over the content item if necessary.
                            IContent contentItem = gcControl.SharedContent;
                            
                        }
                    }
                }
            }


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