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

Forums / Developing with Sitefinity / Dynamic Urls in Custom Index

Dynamic Urls in Custom Index

11 posts, 0 answered
  1. Josh Owens
    Josh Owens avatar
    4 posts
    Registered:
    13 Oct 2009
    18 Jan 2010
    Link to this post
    I am trying to implement a custom search index. I have it up and running using the GetUrlsToIndex. The list all of urls point 
    to the same page with different query string parameters. After running the index Sitefinity is only indexing the last url in
    list. Is there a way to get the custom search index to see the urls as individual pages. Thanks for your help.

    public string[] GetUrlsToIndex() 
            { 
                var urls = new string[] 
                { 
                    "http://mydomain.com/External/Directory.aspx?CategoryID=1&ID=10", 
                    "http://mydomain.com/External/Directory.aspx?CategoryID=2&ID=11", 
                    "http://mydomain.com/External/Directory.aspx?CategoryID=3&ID=12", 
                    "http://mydomain.com/External/Directory.aspx?CategoryID=4&ID=13
                } 
     
     
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    20 Jan 2010
    Link to this post
    Hello Josh Owens,

    I regret to inform you that it would not be possible to get this working. There will be only one page added to the list of pages, not four. I tried to get around somehow, but I could not.

    All the best,
    Ivan Dimitrov
    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. David
    David  avatar
    78 posts
    Registered:
    29 Dec 2008
    01 Feb 2010
    Link to this post
    Hi Ivan,

       Is this still the case, not sure what year the post was made?  I attempting to do the same thing for 600 products.

    David
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    01 Feb 2010
    Link to this post
    Hi David ,

    The case is the same. The post has been made this year, actually 11 days ago.

    Best wishes,
    Ivan Dimitrov
    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. David
    David  avatar
    78 posts
    Registered:
    29 Dec 2008
    01 Feb 2010
    Link to this post
    I was afraid of that.  I did come up with another idea to run by you.  I am thinking about doing a URL rewrite on the server since the company is hosting on their server, where I load the string array with the url like this:

    http://mydomain.com/4h56
    or
    maybe http://mydomain.com/4h56.aspx if they don't have any strange characters in their SKU id.

    The URL redirect would redirect to
    http://mydomain.com/flooring.aspx?sku=4h56

    What do you think of this approach?

    David

  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    01 Feb 2010
    Link to this post
    Hello David ,

    This seems to work. Another option is suing additional url of a page and add the querystring parameter there.

    Greetings,
    Ivan Dimitrov
    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.
  7. David
    David  avatar
    78 posts
    Registered:
    29 Dec 2008
    03 Feb 2010
    Link to this post
    Good Morning Ivan,

       I am not sure if I understand the second option:  suing additional url of a page and add the querystring parameter there.

    Is this creating a page with a hyperlinks to all possible products for the indexer to crawl?

    David
  8. David
    David  avatar
    78 posts
    Registered:
    29 Dec 2008
    04 Feb 2010
    Link to this post
    Can anybody explain this?

    Thanks,
    David
  9. David
    David  avatar
    78 posts
    Registered:
    29 Dec 2008
    04 Feb 2010
    Link to this post
    Hi all,

       I just figure out a solution for a custom search index to an external database of products.  I can now index all products (flooring.aspx?sku=xxxxx).

    1.  Create an URL rewrite for your products.  I went with a rewrite flooringXXXX.aspx (XXXX is the sku value)
         Link to rewrite http://www.sitefinity.com/support/forums/sitefinity-3-x/3-x-pre-release-forums-retired/url-rewriting.aspx
     2. Follow Gabe's instructions for setting up a Custom Index Provider.  Unable to find it, however it is on Sitefinity Watch

    3.  Modified public string[] getlist  then Add a method to the CustomIndexProvider class: 

    01.public string[] GetUrlsToIndex()
    02.        {
    03.            return getlist();
    04.        }
    05. 
    06.        public string[] getlist()
    07.        {
    08.            var db = new Products.ProductsDataContext();
    09. 
    10.            var records = (from c in db.Floorings
    11.                           select c);
    12. 
    13.             
    14.            //Your site url with product page
    15.            string myurl = "http://localhost:4028/mysite/Flooring";
    16.            List<string> mysku = new List<string>();
    17.            string theurl;
    18.            foreach (var item in records)
    19.            {     
    20.                    theurl = myurl + item.SKU + ".aspx";
    21.                    mysku.Add(theurl);
    22.            }
    23.            return mysku.ToArray();
    24.        }
  10. Jeremy
    Jeremy avatar
    14 posts
    Registered:
    29 Jun 2010
    19 Aug 2010
    Link to this post
    Hello David,

    Can you explain these two lines in detail :

    var db = new Products.ProductsDataContext();
    09. 
    10.            var records = (from c in db.Floorings
    11.                           select c);

    Can you provide me with sample code for Products class ?

    I have very similar situation,i am trying to figure out how to search for data which is pushed from external database using query string url paramters concept.

    Thank You,
    Sravanthi
  11. Jan
    Jan avatar
    39 posts
    Registered:
    22 Jan 2010
    07 Dec 2010
    Link to this post
    The code David published is using a Linq datamodel.
    The product class an model of the database. And flooring is an autogenerated class matching the Flooring table

    What you should do is to call some dataprovider and retrieve a dataset or something, if that is how you fetch your data. And then handle it as normal

    foreach(DataRow dr in ds.Tables[0].Rows)
    {
       list.Add("http://localhost/product.aspx?id=" + dr["id"]);
    }

Register for webinar
11 posts, 0 answered