Skip to main content
Inspiring
April 13, 2010
Question

quick shopping cart question - how many web pages ?

  • April 13, 2010
  • 1 reply
  • 840 views

Don't want to use an existing shopping cart - I've written a shopping cart back in 2003 and just need a quick refresher as I'm rusty and haven't use Coldfusion since then...

Background:

Website to sell following types of jewellery categories:

rings

bracelets

pendants

necklaces

Rather than create a web page for each category eg.

rings.cfm

bracelets.cfm

pendants.cfm

necklaces.cfm

Is it better to create a single web page, products.cfm,  that encompasses the above? For maintenance purposes (eg. adding additional categories in future) this would seem the logical approach ?

Digging deeper into the workings of the single webpage, products.cfm, when a user clicks on 'rings' category, products.cfm is reloaded with the appropriate URL eg.

products.cfm?category=rings

the webpage, products.cfm, will contain coldfusion logic that picks this URL up and adjusts the SQL query so it only fetches the items that fall into the 'rings' category eg.

SELECT *

FROM products

WHERE category = rings

Am I on the right track ?

This topic has been closed for replies.

1 reply

ilssac
Inspiring
April 13, 2010

Your mostly on the right track.

Don't use SELECT * is a general rule of thumb, beyond simple demo code.

SELECT *
FROM products
WHERE category = <cfqueryParam value="#url.category#" cfsqltype="...">

But, ColdFusion makes it pretty easy to have your cake and eat it to.

If you would like URLS like:

rings.cfm

bracelets.cfm

pandants.cfm

necklaces.cfm

Which some say can help with search engine optimization.

I have done these two line files before:

rings.cfm

------------

<cfset variables.category = rings>

<cfinclude template="products.cfm">

And then your products.cfm file works exactly the same as above, except you would use variables.catgory instead url.category.  It is pretty easy to use a CFML <cfile....> tag to create or remove these two line files when categories are added or removed.

Inspiring
April 13, 2010

Thanks. Really great info Ian.

So, as a generlal is it better to drop URL passing ? Instead, just use a coldfusion variable like variables.category=rings ?

I suppose this helps improve security ?

ilssac
Inspiring
April 13, 2010

There is a theoritical, but pratically unprovable idea that the URL www.mysalessite.com/rings.cfm is givin a slightly better score then www.mysalessite.com/products.cfm?category=rings. The idea, as I have read it, is that the former url looks more permanent.

But yes, it is also more secure as the the rings.cfm version the variable is not exposed in the browser where the user can monkey with it.  But it is not that hard to protect oneself from URL manipluation.  Just don't forget to do that very important step.