More in this section

Forums / Developing with Sitefinity / Generic content url

Generic content url

6 posts, 0 answered
  1. Paul
    Paul avatar
    176 posts
    Registered:
    18 Nov 2008
    15 Apr 2009
    Link to this post

    Hi! 

    I need to set link to generic content from another generic content. How I can do this without going to the page with my generic content and copy URL of generic content? I want to add URL of another generic content dinamically.

  2. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    15 Apr 2009
    Link to this post
    Hi Paul,

    We also generate the URL of the Content Items dynamically. We take the URL format for this from the web.config file, and the property UrlRewriteFormat property of the Generic Content Provider. You can use it in order to determine how the url should look like, then take the content items you need with our API.

    Regards,
    Georgi
    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. Paul
    Paul avatar
    176 posts
    Registered:
    18 Nov 2008
    20 Apr 2009
    Link to this post

    Hi!

    I understand that I have ID of generic content item but what I gonna do with this ID? How can I open some generic content from other content? And how can I set link to this content in generic content? Maybe you have some controls which help me to set link not to the page but to the generic content item?

    Thank you.

  4. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    23 Apr 2009
    Link to this post
    Hi Paul,

    Having a second read of the case, I believe that I could suggest you a different solution.

    I assume that when you are working with the RadEditor, you want to have a tool (just like the image manager, or the link manager) which shows you the Generic Content items that you have. Then, you can select from this list an item, and insert a link in the currently edited item. Am I correct?

    In this case:
    1. You could create a custom RadEditor tool dialog - it is just a aspx page linked to the editor. This page should take out the Generic Content items, and when they are clicked, it will have to insert the selected item in the editor. We are doing this with the links, so you could see the logic in the Links dialogs.
    2. Since the generic content items are just a piece of information, but not an actual page. Therefore, we should not just take the items, but also take the pages, on which these items are placed.
    3. Getting all content items:
            ContentManager m = new ContentManager("Generic_Content"); 
            IList myItems = m.GetContent();
        //by ID  GetContent(ContentID);
     
            foreach (IContent item in myItems) 
            { 
                string title = item.GetMetaData("Title").ToString(); 
                Response.Write(title); 
            } 

    4. Finding a page, containing a Generic Content control with shared content item:
    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)); 
                } 
            } 
        } 

    I hope these snippets will help you. Note that the code is not fully tested.

    Georgi
    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.
  5. Paul
    Paul avatar
    176 posts
    Registered:
    18 Nov 2008
    23 Apr 2009
    Link to this post

    Wow!

    Hi Georgi!

    Your snippets are greate! You really help me!

    Thank you!

  6. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    23 Apr 2009
    Link to this post
    Hello Paul,

    I am glad that you find them helpful.
    Let me know if you have any other questions.

    Best wishes,
    Georgi
    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
6 posts, 0 answered