Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Generate Dynamic Webpage for Shop Items

  1. #1
    Join Date
    Aug 2011
    Location
    UK
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation Generate Dynamic Webpage for Shop Items

    Hi,

    I'm quite an experienced programmer, but haven't come across this situation previously...

    I have an on-line shop which is driven from shop.php. The shop.php generates a list of items based on set categories. The items are extracted from an XML file (XPath). The generated links to each shop item, e.g. shop.php?item=123456, are rewritten as 123456/bike1.html, defining each item.

    All items are contained within an XML structured file, with the relevant data for image, title, description etc...

    My issue is how to build a central piece of code to generate the required output webpage to display an item, e.g. bike1.html, when the product item link is clicked and render to the user?

    Thanks for any help,

    Mark.

  2. #2
    Join Date
    Mar 2007
    Location
    New York, NY
    Posts
    557
    Thanks
    8
    Thanked 66 Times in 66 Posts

    Default

    Be a little more specific. Is every single product information stored in an XML node in one centralized XML sheet? (similar to this):
    Code:
    <product>
    <product_id>12345</product_id>
    <description>THis is a description...</description>
    <price>$0.00</price>
    </product>
    <product>
    <product_id>54321</product_id>
    <description>THis is a description...</description>
    <price>$0.00</price>
    </product>
    It sounds like it, by what you said.

    I don't understand your change in URL structure. You said shop.php?item=12345 would be changed to 12345/bike1.html, but should shop.php contain the query string for bike1? Something like shop.php?item=12345&detail=bike1

    I really don't have anything to work with, so I can't provide much help. But here's the PHP documentation on accessing XML objects using DOMDocument:
    http://php.net/manual/en/class.domdocument.php

    Hope this helps.

  3. #3
    Join Date
    Aug 2011
    Location
    UK
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation

    Hi,

    thanks for the reply, and the XML products file is similar to your example, but the XML is not the issue...

    The data is extracted from the XML file based on a menu selection to retrieve product items for a specific category, e.g. retrieve the Item No. product description, etc...

    What I want is to create a link to display the product item on an individual webpage. The webpage must execute a look-up based on the Item No. to retrieve a full description and extra image files etc. e.g. need to create the bike1.html on the fly.

    I hope that makes more sense, or perhaps clouds the issue.

    Best wishes,

    Mark.

  4. #4
    Join Date
    Mar 2007
    Location
    New York, NY
    Posts
    557
    Thanks
    8
    Thanked 66 Times in 66 Posts

    Default

    You can access XML nodes through JavaScript and have it display dynamic content on the fly, if that's what you're looking to do.

  5. #5
    Join Date
    Aug 2011
    Location
    UK
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation

    Hi,

    The XML retrieval of the data is not a problem , the aim is to improve the SEO capability of the web-pages.

    I need to generate the HTML file per product item click, so that the search-engine Bots will index web-page per product item.

    I don't want to manually create a web-page for each item, but create on the fly. I suppose it could be done through some fancy rewriting in .HTAccess...

    Thanks again,

    Mark.

  6. #6
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    how is the item info currently displayed to the user? what happens when the user clicks on one of those links?

  7. #7
    Join Date
    Aug 2011
    Location
    UK
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation

    Hi,

    currently no webpage for individual product items, you can only add to the shopping cart from the categorised list of items.

    Thanks,

    Mark.

  8. #8
    Join Date
    Mar 2007
    Location
    New York, NY
    Posts
    557
    Thanks
    8
    Thanked 66 Times in 66 Posts

    Default

    Well, you could create files using something like this to create files:

    PHP Code:
    $data = <<<EOF
    <html>
    <head>
    <title>Bike 1</title>
    <meta name="keywords" content="" />
    <meta name="description" content="" />
    </head>
    <body>
    content here
    </body>
    </html>
    EOF;

    $filefopen("bike1.html"'w');
    fwrite($file$data);
    fclose($file); 
    And that would create an HTML file with META tags in the head for description, keywords, etc which would improve SEO.

  9. #9
    Join Date
    Aug 2011
    Location
    UK
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation

    A neat solution...

    Will the output render to the browser or just create the webpage?

    Thanks.

  10. #10
    Join Date
    Mar 2007
    Location
    New York, NY
    Posts
    557
    Thanks
    8
    Thanked 66 Times in 66 Posts

    Default

    It would create the web page, but you could also put in a redirect in your code to redirect to that web page.
    - Josh

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •