Copied to clipboard

Flag this post as spam?

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


  • Chris Langston 4 posts 24 karma points
    Jun 19, 2011 @ 04:05
    Chris Langston
    0

    How to dynamically generate pages from a database table

    I would like to be able to dynamically generate pages from data stored in a table in the database.    There would be a Home page and then some type of Category (i.e. Horses) that will contain n number of entries.

    If someone clicks on Horses, I would like to be able to dynamically pull all the various breeds of horses from the database and then dynamically generate the appropriate pages, but not have to create the physical pages inside of the Umbraco back-end.

    1. The page structure would be like root\horses\
    2. When the horses page is generated, there would be a hyperlinks for A, B, C, etc. for all the appropriate Horse breeds where the breeds would be pulled from a database table that contained breed information (id, name, short-description)
    3. When someone clicks on the hyperlink for say “S” for Stallion, I would like for it to pull all the information about the stallion from the database.  I would see the page being root\horses\stallion (or .aspx ending)
    4. There could potentially be 100’s if not thousands of these entries where I don’t want to manage all the physical pages in the back-end of Umbraco.

      What’s the best practice for implementing this type of functionality?


    I’m new to Umbraco, so I’m trying to quickly get up to speed and wrap my head around how these pages would be rendered without the phyical pages in the umbraco back-end.


    Thanks for any helpful tips or articles you can provide.

    Chris

  • Chris Dunn 210 posts 401 karma points
    Jun 19, 2011 @ 04:37
    Chris Dunn
    0

    Chris,

    The content is easy enought to pull from the database.  You can use xslt, razor or .net usercontrols...depending on you personal flavor.

    The easiest if you come from a background in .net would be usercontrols.  You could also write helper methods or extensions for the other two.

    You then create a page and drop the user control on the template of that page.  This will handle the dynamic page display from the database tables.  Program the user control to handle querystring values to determine which breed or type of horse to call the record(s) for...or any other criteria and pull that data from the database using normal .net code.

    http://www.yoursite.com/detail.aspx?category=horse&type=stallion

    The page url can be handled by url rewriting to convert:

    http://www.yoursite.com/horses/stallion

    to

    http://www.yoursite.com/detail.aspx?category=horse&type=stallion

    You're basically using umbraco to host your usercontrols and using rewriting to make it look like the pages exist in umbraco.

    Many ways to do it but I hope that gets you started.

    -Chris

  • Chris Langston 4 posts 24 karma points
    Jun 19, 2011 @ 04:59
    Chris Langston
    0

    Thanks for the reply and I appreciate the guidance.

    My background is certainly more .net and user controls than xslt/razor (at the moment).

    Can you explain in just a little more detail what you mean by "The page url can be handled by url rewriting to convert (root/horses/stalion) to (root/deail.apx?category=horse&type=stallion")?

    Let me see if I follow the steps you list above:

    1. I would create a page inside of Umbraco back-end and name it for instances (details.aspx)
    2. The page that generates all the breeds of  horses would have the url for each item (i.e. letter S for Stallion) <a href="/details.aspx?category=horse&type=stallion)
    3. I create a user control that reads the post-back for the query string parms (category and type) and pull out those values.
    4. Here's where I'm confused.  What do I do to create the actual url to show up as (root/horses/stallion) for SEO optimization?  Is this some type of plug-in to IIS or ASP.NET?  I want to search engines to link to the specific pages instead of root/details.aspx?category=type.

    Thanks again,

     

    Chris

  • Chris Dunn 210 posts 401 karma points
    Jun 19, 2011 @ 05:46
    Chris Dunn
    0

    Umbraco has url rewriting which uses urlrewriting.net...you can find the file in the config folder as urlrewriting.config.  This file contains your rewrite rules.

    It's part of umbraco install so nothing to new to install.  IIS 7 also has url rewriting which could also be used.  

    Basically it says if this pattern comes in, process the request using "x" page.  So the umbraco page doesn't have to actually exist.  

    The config file contains some sample rules and more info about rewriting.  It shows a product detail page url which is similar to what you're looking for.

    also the main docs:

    http://urlrewriting.net

    You may need more than one page and one user control for each type of information (category display, detail display), depending how to do it. But the concept is the same.

    When you list the breeds for example and have links to those pages, build it SEO friendly vs the query string version.

    <a href="/horses/stallion">View Stallion</a>  rather than <a href="/detail.aspx?category=horse&type=stallion">View Stallion</a> 

    Once urlrewriting is configured, it will handle passing the request back to the right page (querystring version).

    -Chris

Please Sign in or register to post replies

Write your reply to:

Draft