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

Forums / Developing with Sitefinity / Generate a sitemap from dynamic data

Generate a sitemap from dynamic data

6 posts, 0 answered
  1. Jan
    Jan avatar
    39 posts
    Registered:
    22 Jan 2010
    04 Nov 2010
    Link to this post
    I have a product page that retrieves data from an external db.
    The problem is that if I want to generate a sitemap (to post to google or have at a page) the product page will only be displayed once (as expected)
    What I would like to do is to generate a structure with all pages (they also have categories and they will also be generated)

    I use the urlrewriter so that http://mysite/products/myCat/myProd will end up at http://mysite/products.aspx?catId=myCat&prodId=myProd.

    The end result should be generated as
    mysite
    - myStandardPage
    - mySecondPage
    - products
    -- mycat1
    --- myProd1
    --- myProd2
    -- myCat2
    --- myProd3
    --- myProd4

    I've tried to find info about this but not been able. Is there any information that can take me forward in my work?

    Edit: The myProd1 link should then be pointed to the http://mysite/products/myCat1/myProd1 url
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    04 Nov 2010
    Link to this post
    Hi Jan,

    You need to generate an XML file with the data from your database. The XML should have the following structure

    <siteMap>
      <siteMapNode title="Node Title" description="Node Descrioption" url="~/default.aspx">
        <siteMapNode title="Node Title 1 " description="Node Title 1"
          url="~/Products.aspx">
        </siteMapNode>
     </siteMapNode>
    </siteMap>

    Depending on the levels you want to have you should generate additional nested siteMapNode elements. You might find this article useful.

    Kind regards,
    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
  3. Jan
    Jan avatar
    39 posts
    Registered:
    22 Jan 2010
    08 Nov 2010
    Link to this post
    Hi

    we figure we build our own custom sitemap provider, but since we have multi language support we need to do handle this in our provider. If I look at some examples I found it's looks something like this for handling pages

    Telerik.Cms.CmsManager cmsManager = new Telerik.Cms.CmsManager();
    System.Collections.IList pages = cmsManager.GetPages(Guid.Empty);
     
    foreach (Telerik.Cms.ICmsPage page in pages)
    {
        SiteMapNode node = new SiteMapNode(this, page.ID.ToString(), page.DefaultUrl.Url, page.MenuName);
        base.AddNode(node, this.root);
        this.LoadPagesRecursive(node, page);
    }

    The ICmsPage know some how what language it should display. Is there any way we can retrieve this information from our own classes?
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    08 Nov 2010
    Link to this post
    Hello Jan,

    You can use page.LanguageVersions.Values which returns IPageContent. You can show the pages on your public site depending on the culture by setting CurrentUICulture.

    All the best,
    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
  5. Jan
    Jan avatar
    39 posts
    Registered:
    22 Jan 2010
    08 Nov 2010
    Link to this post
    Yes, but since I don't build by provider based on page content that may be a problem.
    Of course each node will lead to a page and I can check that pages settings.

    I don't know what the SitemapProvider will generate and what will be done in runtime but I try to explain

    We have (as I posted in first post) a db with all the products/categories etc.
    we want to build a sitemap to use for some menus. This we figure out is best done by building a staticSitemapProvider.

    All products have diffrent name in diffrent languages. It may be called "Shovel" in english but "Spade" in swedish.
    In the code above I took a ref to an example I found and they used the page object when building the sitemap

    SiteMapNode node = new SiteMapNode(this, page.ID.ToString(), page.DefaultUrl.Url, page.MenuName);

    Here they send in page.MenuName (will be diffrent depending on the language)?

    Will this sitemap be in one instance for each language or how does this works? We need to somehow take diffrent fields from our db to send into the "title" parameter of SiteMapNode.
    The pages are comming from cmsManager.GetPages, and I figure that it is there you will filter out just the active pages for that language, and is it also there the page knows the active language?

    Do you follow me? I want to be able to tell the language of the sitemap beeing generated.
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    08 Nov 2010
    Link to this post
    Hi Jan,

    In your table you should have a column where you set the culture ID, so you can identify which name will be loaded depending on the CurrentUICulture. You need one SiteMap provider which gets the pages related only to this culture. GetPages method returns all pages for the current culture - there is a table in the database where we keep the IDs of the culture and our data layer, when makes a transaction/call knows what to get depending on the CurrentUICulture

    Kind regards,
    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
Register for webinar
6 posts, 0 answered