Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • marthin 87 posts 106 karma points
    Sep 14, 2010 @ 10:17
    marthin
    0

    Get correct product page

    Hi all,

    I have a umbraco installatio with multiple sites. They all extend a custom section where they set up there own product registry. (simple list with products that are uniq for there company), The nodes craeted here are in there own DB table, not in umbracoNodes.

    My problem is this: I want to be able to write in a url like "randomsite.com/products/cat1/cat2/product2.aspx"

    and this will then correctly go to the product with id=2 in a deepth of cat1/cat2.

    In my Url rewriting iv currently got:

    <add name="produktidrewrite"
                        virtualUrl="^~/products/(.*)/(.*).aspx"
                        rewriteUrlParameter="ExcludeFromClientQueryString"
                        destinationUrl=""
                        ignoreCase="true" />

     

    But since i do not know where the companies have there productlisting page in there content tree i dont know how to get the destinationUrl???

    Lets say that two companies may have the folllowing content struktures:

    Company A

       - Page 1

      - Product listing page

     

    Company B

      - Page 1

      - Some page

               - Product listing

     - Some other page

     

    Could I solve this by some XSLT or something?  The public view of product listing is implemented as a user control with some fancy Jquery menu for product categories.

     

    Thx for taking your time with this!

    Best Regards

    Marthin

  • Sascha Wolter 615 posts 1101 karma points
    Sep 14, 2010 @ 12:07
    Sascha Wolter
    0

    Hi Marthin,

    how about creating a common target node for the products, something like a product redirect page, which is instantiated in all web sites (e.g. each company will have a '/products' page). The rewrite rule will forward all requests to this page with the id of the product in the query string. Now on the product redirect page you then figure out where the products are sitting for the specific site you are in, and then it does the correct redirect, e.g. with Server.Transfer('correct-products-url') to avoid ping-pongs. You can even create a product node property on the redirect page as content picker so you don't even need to look it up each time. That is a bit of a hack, but not too much and should work fine.

    Hope that makes sense,

    Sascha

  • marthin 87 posts 106 karma points
    Sep 14, 2010 @ 12:48
    marthin
    0

    Hi Sascha, thx for taking the time!

    I know that i will need a single landing page for all products, that big problem is to locate the product listing in the content tree since this could be implemented anywhere.

    How would i do to implement that kind of content picker? (i havent been using umbraco for a while som im a bit confused when it comes to the names of everything)

    Thx again!

  • Sascha Wolter 615 posts 1101 karma points
    Sep 14, 2010 @ 13:27
    Sascha Wolter
    0

    Hi Marthin,

    just to clarify: you would need a single landing page for all products per site. This will make it much easier to locate the proper product listing node.

    So let's say you create a new document type with a template and an alias of 'Product Listing Finder'. On that you create a new tab called 'product listing locator'. Under this tab you create a new property, call it whatever you want, give it an alias of e.g. productListingLocation and a type of content picker. 

    Now in the content tree you create a new page of this type for every company, so it looks something like

    Company A

       - Page 1

      - Product listing page

      - Product redirect 

     

    Company B

      - Page 1

      - Some page

               - Product listing

     - Some other page

     - Product redirect

     

    In the UrlRewriting rule you can then choose this as destination url, it will automatically find the correct one for each company based on the url/host name the user is on. 

    In the template now you just add a new .Net macro which you have created and uploaded to the server, no need for anything else in the template really. In the .Net user control you do something like this:

    int productId = Request.QueryString["id"].ToString();

    Node current = Node.GetCurrent();

    int productListingNodeId = int.Parse(node.getProperty("productListingLocation").Value.ToString());    //check if property exists and is not empty; use TryParse!

    Server.Transfer(umbraco.library.NiceUrl(productListingNodeId) + "?id=" + productId);

    I've written that out of the top of my head, might need some tweaks here and there, yet I hope you get the idea. You can do this without the property and manually setting the product listing page reference, you would just have to find the top node of the company site you are currently on and then get the node with the product listing doc type alias. However since the node will probably stay the same it seems a better solution to do it with a content picker property so you don't have to traverse the tree all the time.

    Hope that makes sense,

    Sascha

     

  • marthin 87 posts 106 karma points
    Sep 15, 2010 @ 09:38
    marthin
    0

    Hi again Sascha!

    Now I understand what you mean! Im not sure wich solution im going with yet. You see my problem is that I will not controll the different companie sites, there will be some people who have absolutley no computer experience that will administrate them wich probably mean that i cant go with a document type that needs a "locator property". I probably need to treverse the tree to find the correct "porduct listing" node. If i do this, do you think I could use some kind of caching to hold the treversed value or some kind of session value? Any recommandations on this?

     

    Thank you so much for helping me out here!

     

    Best Regards

    Marthin

  • Sascha Wolter 615 posts 1101 karma points
    Sep 15, 2010 @ 19:17
    Sascha Wolter
    0

    Hi Marthin,

    glad it makes sense and actually helps you! :)

    You can easily e.g. use the HttpRuntime.Cache for this:

            public static int GetProductListingNodeId()

            {

        string host = "company-a"; //dynamically get the company who's side you are on; needed to prefix the cache value, otherwise you create chaos

                if (HttpRuntime.Cache[host + "_productListingNodeId"] != null)

                {

                    //use from cache

                    return (int) HttpRuntime.Cache[host + "_productListingNodeId"];

                }

     

                //build new

                // -> traverse the tree and dynamically retrieve the product listings node id for this company (-> host name)

        int nodeId = 1234;

     

                //add to cache (24 hours)

                HttpRuntime.Cache.Add(host + "_productListingNodeId", members, null, DateTime.Now.AddHours(24), Cache.NoSlidingExpiration,

                                      CacheItemPriority.Normal, null);

     

                return nodeId;

            }

    Might contain some typos, yet should be enough to highlight what I mean. 

     

    Cheers,

    Sascha

Please Sign in or register to post replies

Write your reply to:

Draft