Solved

Why my coldfusion pages takes ages to load

Posted on 2014-02-20
37
455 Views
Last Modified: 2014-03-19
Hi experts,

WE are still puzzeld about our webiste beeing so slow for some pages.

Like this one :

http://www.joe-cool.co.uk/EN/products/products_results.cfm?catname=All%20bracelets&rngname=all&items=20&page=1&sortby=novelty


It takes over 2 minutes to load nad I don't see why, the MySql DB is indexed, there is over 5000 stock items and we don't think that is so much

Thansk for your replies

Adam
0
Comment
Question by:adam1h
  • 13
  • 12
  • 11
  • +1
37 Comments
 
LVL 24

Expert Comment

by:mankowitz
ID: 39873747
In order to help, please post just the mysql part of your question, including the query that is running slowly. Also, please post your database structure and some sample data. That will make it much easier to help you.
0
 
LVL 24

Expert Comment

by:dgrafx
ID: 39873943
one thing is that I believe you are querying for all of your products when you are showing only x number per page view.
and then when you go to the next page you query for all of them again and show the next x number - and so on ...
you should query to return only x number of records from the db back to the page.
this will speed the process greatly.
i can give you code for sql server that you can translate to mysql.

there may be other issues such as how your query or db is built as well.

post your query
post your table structure

we can then try and help you solve the issue.
0
 
LVL 52

Expert Comment

by:_agx_
ID: 39874307
In addition to the other comments, make sure you're not doing anything resource intensive like re-querying within a loop. For example, running one query to get all products

        <cfquery name="getProducts" ....>SELECT * FROM Products </cfquery>

Then running another query for each individual product as you display the results:

         <cfoutput query="getProducts">
                <cfquery name="getDetails" ..>
                     SELECT Columns
                      FROM   OtherTable
                      WHERE  ProductID = <cfqueryparam value="#ProductID#" ....>
                </cfquery>

                ... show product details....
         </cfoutput>

Hitting the db once for each record adds a lot of server network o/h and can significantly slow things down.  Instead use a JOIN to retrieve all of the details in a single query - and of course paginate - as drgafx mentioned.

But these are just guesses based on common causes. As mentioned, we need to see the actual queries/code to pinpoint the cause.
0
 

Author Comment

by:adam1h
ID: 39874391
Hi to all,

Many thanks for your comments and help. We do use a .cfc as the component and we display the results in a .cfm page, I presume you would like the component content :-)

I can't unfortunately provie your the DB structure, as I got to go, but all the stock data is in a single table, but also calls the customer table for customer 's different types.
Thanks again, please see the code below :
<cfcomponent displayname="products_results">
	<!--- fields --->
	<!-------------->
	<cfset This.rngname = "">
	<cfset This.catname = "">
	<cfset This.results = StructNew()>
	<cfset This.totalItems = 0>
	
	<!--- init method --->
	<!------------------->
	<cffunction name="init" access="public" output="true" returntype="products_results">
		<cfargument name="range" required="yes" type="string">
		<cfargument name="cat" required="yes" type="string">
		<cfargument name="sortby" required="yes" type="string" default="highestPrice">
		<cfargument name="itemsPerPages" required="yes" type="string">
		<cfargument name="page" required="yes" type="string">
		<cfargument name="inStockOnly" required="no" type="string" default="no">
			
			<!--- collect range and cat --->
			<cfset This.rngname = Arguments.range>
			<cfset This.catname = Arguments.cat>
			<cfset This.sortbyname = Arguments.sortby>
			
			<!--- set the right price field --->
			<cfif Session.buyerCat EQ "consumer">
				<cfif Session.currency EQ "gbp">
					<cfset priceType = "jcpric1">
				<cfelseif Session.currency EQ "eur">
					<cfset priceType = "apprice">
				<cfelseif Session.currency EQ "usd">
					<cfset priceType = "usdretail">
				</cfif>
			<cfelseif Session.buyerCat EQ "wholesaler" OR Session.buyerCat EQ "AP">
				<cfif Session.currency EQ "gbp">
					<cfset priceType = "jcpric2">
				<cfelseif Session.currency EQ "eur">
					<cfset priceType = "eurwhlsl">
				<cfelseif Session.currency EQ "usd">
					<cfset priceType = "jcnote09">
				</cfif>
			<cfelseif Session.buyerCat EQ "bulk">
				<cfif Session.currency EQ "gbp">
					<cfset priceType = "jcpric3">
				<cfelseif Session.currency EQ "eur">
					<cfset priceType = "eurbulk">
				<cfelseif Session.currency EQ "usd">
					<cfset priceType = "usdbulk">
				</cfif>
			</cfif>
			
			<!--- gets the results (relevant to be displayed) --->
			<cfquery name="queryFiltered" datasource="joecool_web">
				select SQL_CALC_FOUND_ROWS jcId from jcstktabl where <cfif This.catname NEQ "all">jccatname = '#Arguments.cat#' and </cfif> <cfif This.rngname NEQ "all">jcmat1 = '#Arguments.range#'  and </cfif> jcid >= '#Application.newItems#' 
				<cfif session.buyerCat EQ "consumer">and jcid not like '%COM' 
				<!---AND jcid not in (select jcidRef from jcstktabl_cropped where jcidRef LIKE jcstktabl.jcid)--->
				<cfelse>and jcid not like '%!_%'escape '!'
				</cfif>
				<cfif inStockOnly EQ "yes">and jcstock > '0' and jcavail not like '%-%' </cfif>
				<cfif Session.buyerCat EQ "consumer">and jccatname not like 'Display stand' and jccatname not like 'Display aid' and jccatname not like 'Gift packaging'</cfif>
				and jcid not in (select j.jcid from oldPrices o, jcstktabl j where o.jcid = j.jcid and o.#priceType# > j.#priceType# and (100-( j.#priceType#/o.#priceType#*100)) >= 20)
				order by <cfif Arguments.sortby EQ 'novelty'>jcid desc
						<cfelseif Arguments.sortby EQ 'highestPrice'>#priceType# desc, jcid desc
						<cfelseif Arguments.sortby EQ 'lowestPrice'>#priceType# asc, jcid desc
						<cfelseif Arguments.sortby EQ 'special'>jcspoff desc, jcid desc
						<cfelseif Arguments.sortby EQ 'bestseller'>jcbestsell asc, jcid desc</cfif>
				limit #(Arguments.page-1)*Arguments.itemsPerPages#, #Arguments.itemsPerPages#
			</cfquery>
			<cfquery name="total" datasource="joecool_web">
				select FOUND_ROWS() AS total
			</cfquery>
			<cfset This.totalItems = total.total>
			
			<!--- create the struct to keep products --->
			<cfset cQueryTool = createObject("component", "model.queryTool").init(queryFiltered)>
			<cfset This.results = "#cQueryTool.toStructAsc("jcId")#">
		<cfreturn this />
	</cffunction>
	
	<!--- private methods --->
	<!----------------------->
	
	<!--- public methods --->
	<!---------------------->
</cfcomponent>>

Open in new window


**Reformatted by Netminder 2 Mar 2014**
0
 
LVL 24

Expert Comment

by:dgrafx
ID: 39874491
i was thinking that the comment by agx is probably the most likely suspect

i can see now you are inserting your query to a structure - this is the main culprit.

there are other things as well -
don't use LIKE
don't use NOT IN () - use WHERE NOT EXISTS ()

just query using db pagination and just return the query object to the page and you only need one query for this.

post back for what help you may need ...
0
 
LVL 52

Expert Comment

by:_agx_
ID: 39875304
dgrafx's probably right about the structures, but what exactly does this part of the code do:

          <cfset This.results = "#cQueryTool.toStructAsc("jcId")#">

?  I can see you're passing in a list of id's. How many and what does toStructAsc do with them?

Also, totally unrelated to performance issues - you're not storing this component in a shared scope, correct? If so, you'll have thread safety issues due to the use of THIS and lack of VAR scoping.
0
 

Author Comment

by:adam1h
ID: 39877052
Hi guys,

Thanks for your sugestions.

I have remove the struct, now I work directly with the query’s resulset.
This is more logic indeed.

I only query the 20 pages needed in the query.

But the performance are +/- the same :(
0
 
LVL 24

Expert Comment

by:dgrafx
ID: 39877089
what do you mean you only query the 20 pages?
are you meaning 20 pages or 20 records?

can you post your new query and also the code on your .cfm page that calls the query function please.
0
 

Author Comment

by:adam1h
ID: 39877127
Oups :) Indeed I mean 20 records

Here is the new query :
<cfquery name="queryFiltered" datasource="joecool_web">
	select SQL_CALC_FOUND_ROWS jcId from jcstktabl where (#REReplace(This.catname,"''","'","ALL")#) and <cfif This.rngname NEQ "all">jcmat1 = '#Arguments.range#'  and </cfif> 
	<cfif session.buyerCat EQ "consumer"> jcid not like '%COM' 
	<cfelse> jcid not like '%!_%'escape '!'
	</cfif>
	<cfif inStockOnly EQ "yes">and jcstock > '0' and jcavail not like '%-%' </cfif>
	<cfif Session.buyerCat EQ "consumer">and jccatname not like 'Display stand' and jccatname not like 'Display aid' and jccatname not like 'Gift packaging'</cfif>
	and jcid not in (select j.jcid from oldPrices o, jcstktabl j where o.jcid = j.jcid and o.#priceType# > j.#priceType# and (100-( j.#priceType#/o.#priceType#*100)) >= 20)
	order by <cfif Arguments.sortby EQ 'novelty'>jcid desc
			<cfelseif Arguments.sortby EQ 'highestPrice'>#priceType# desc, jcid desc
			<cfelseif Arguments.sortby EQ 'lowestPrice'>#priceType# asc, jcid desc
			<cfelseif Arguments.sortby EQ 'special'>jcspoff desc, jcid desc
			<cfelseif Arguments.sortby EQ 'bestseller'>jcbestsell asc, jcid desc</cfif>
	limit #(Arguments.page-1)*Arguments.itemsPerPages#, #Arguments.itemsPerPages#
</cfquery>
<cfquery name="total" datasource="joecool_web">
	select FOUND_ROWS() AS total
</cfquery>
<cfset This.totalItems = total.total>
<cfset This.results = queryFiltered>

Open in new window


and the cfm page who calling it :
<cfscript>
	products_instance = CreateObject("component", "products_results").init(range="#url.rngname#", cat="#url.catname#", sortby="#url.sortby#", inStockOnly="#Session.inStockOnly#", itemsPerPages="#url.items#", page="#url.page#");
</cfscript>

...

<table width="900" align="center">
  <cfif products_instance.results.RecordCount EQ 0><tr><td width="900" align="center" valign="middle">Sorry, no products for this category now</td></tr></cfif>
  <!---<cfif StructCount(products_instance.results) EQ 0><tr><td width="900" align="center" valign="middle">Sorry, no products for this category now</td></tr></cfif>--->

  <cfset displayCounter = 0>
  <cfset counter = 0>
  <cfloop query="products_instance.results">
  <!---<cfloop index="counter" from="1" to="#Session.ItemDisplayed#" step="1">--->
	  <cftry>
		  <cfsavecontent variable="thumb">
			  <cfoutput>
				<cfset counter ++>
				<cfset displayCounter ++>
				<cfif displayCounter EQ 4>
					<cfset displayCounter = 1>
				</cfif>
				<cfif displayCounter EQ 1>
					<tr>
				</cfif>
				<td width="300" align="center" valign="middle">
					<!---<cfset i = products_instance.results["#counter#"].jcid>
					<cfinvoke component="#Application.Allproducts#" method="displayThumbs" id="#i#">--->
					<cfinvoke component="#Application.Allproducts#" method="displayThumbs" id="#jcid#">
				</td>
				<cfif counter EQ #Session.ItemDisplayed# >
					<cfif displayCounter EQ 1>
						<td width="300" align="center" valign="middle">&nbsp;</td>
						<td width="300" align="center" valign="middle">&nbsp;</td>
					<cfelseif displayCounter EQ 2>
						<td width="300" align="center" valign="middle">&nbsp;</td>
					</cfif>
					<cfset displayCounter = 3>
				</cfif>
				<cfif displayCounter EQ 3>
					</tr>
				</cfif>
			  </cfoutput>
		  </cfsavecontent>
		  <cfoutput>#thumb#</cfoutput>
	  <cfcatch type="any"><cfset displayCounter -- ></cfcatch>
	  </cftry>
  </cfloop>
  </table>

Open in new window


Next step : I will transform NOT IN () with use WHERE NOT EXISTS ()

But how can I avoid like’s ; I can replace some, but other are needed to use wildcards.

Thanks for your help.
0
 
LVL 52

Assisted Solution

by:_agx_
_agx_ earned 300 total points
ID: 39877199
Did you:

1) Check the cfquery time? We are assuming the query is consuming the bulk of the time, not the rest of the CF code, but you should confirm that.
2) Did you run the raw query directly in MySQL to see how long it is taking? Also, do an EXPLAIN PLAN to understand how the db is executing the query. As you make changes, it will also help you gauge whether or not they improve the execution plan.
3) I noticed you're invoking another cfc within the output loop. What does this code do ? Any queries inside it?
<cfinvoke component="#Application.Allproducts#"
0
 
LVL 24

Assisted Solution

by:dgrafx
dgrafx earned 200 total points
ID: 39877204
just to test where the bottleneck is do the following

hard code a query selecting 1000 records using the columns that you'd normally have and don't use LIKE and don's use NOT IN.
one issue at a time
this is to try and find the issue

i'm fairly unfamiliar with mysql
if you type #queryFiltered.recordcount# what is the value? using the code you have now.

and yes - what's with the additional <cfinvokes in the output blocks?
0
 
LVL 52

Assisted Solution

by:_agx_
_agx_ earned 300 total points
ID: 39877291
EDIT: I wrote this up before seeing the other responses. Agreed - you should take it one step at a time. But some observations for later ...

But how can I avoid like’s ; I can replace some, but other are needed to use wildcards.

There are different techniques, such as assigning the categories you want to filter to different groups with an ID. Then filter on the numeric group id's you want to include or exclude .. or doing the same with boolean property flags. But ... that requires a normalized structure. It looks like your db tables are not normalized. Category names should not be stored within the stock table. The unique categories should be stored in a separate table:

     Table: Category /  Columns: CategoryID, CategoryName

... and only the category ID stored in the  "Stock" table as a FK. The use JOIN's when you need to filter on or retrieve the category names. The db will optimize queries on the smaller (unique) set of category names more efficiently searching through 5K names. Plus it eliminates data integrity problems by not duplicating category names.

          SELECT  sc.CategoryName
          FROM    TheStockTable st INNER JOIN Category sc
                             ON sc.CategoryID = st.CategoryID

Second, performing functions or operations on a where clause column can cause the db to ignore indexes. If possible, you should eliminate this kind of runtime evaluation.  Also, if those variables are user supplied, you're exposing your db to sql injection.

                             and   (100-( j.#priceType#/o.#priceType#*100)) >= 20

Side note. you only need LIKE when using wildcards. Otherwise, just use equals "=".

                       <cfif Session.buyerCat EQ "consumer">
                           and jccatname not like 'Display stand'
                           and jccatname not like 'Display aid'
                           and jccatname not like 'Gift packaging'
                       </cfif>

... and for multiple comparisons, it is a little cleaner to use IN (....) instead of multiple AND's. So you could rewrite the above as:
 
            WHERE ColumnName NOT IN ('Display stand' , 'Display aid' , 'Gift packaging')

Though again, I really think you need to normalize so most of your matches will be on numeric id's (quicker) not strings.
0
 
LVL 52

Expert Comment

by:_agx_
ID: 39877732
Just noticed your outer query "queryFiltered" only returns a single ID column. That means you must be running separate queries for each record in the cfoutput ie 20 records == at least 20 additional queries. That would explain the slowness.

You want to run a *single* query, using JOINs to get the results. Not one query per id. Can you post the code for :

<cfinvoke component="#Application.Allproducts#"
0
 
LVL 24

Expert Comment

by:dgrafx
ID: 39877818
And you are invoking it 2 times ...
0
 

Author Comment

by:adam1h
ID: 39882104
Hi all,

I have run the query with the explain command, here are the details :

query-original.tiff

And here are the details for the query by replacing not like with !=

query-modified.tiff

It not seems to take so much time. Do you know what is the unit for the time ? Is it miliseconds ?
0
 
LVL 52

Expert Comment

by:_agx_
ID: 39883715
It's in milliseconds, but that's not the time for the search query - it's how long it takes mySQL generate the EXPLAIN PLAN result.  

Also, you forgot to post the code for <cfinvoke component="#Application.Allproducts#" . I have feeling that's where the problem lies...
0
 

Author Comment

by:adam1h
ID: 39884983
Hi _agx_,

Thanks for trying to help, very much appreciated here. Her eis what is lying under application.allProducts :
Product_collection.cfc, and here is the code it contains.

<cfcomponent displayname="products_collection">
	<!--- fields --->
	<!--------------->
	
	<!--- init method --->
	<!----------------------->
	<cffunction name="init" access="public" output="yes" returntype="model.products_collection">
		<!--- retrieve products from database (jcstktabl) --->
		<cfquery name="q" datasource="joecool_web">
			select * from jcstktabl order by jcid desc
		</cfquery> 
		
		<!--- create the session struct to keep products --->
		<cfset cQueryTool = createObject("component", "queryTool").init(q)>
		<cfset This.products = "#cQueryTool.toStruct("jcId")#">
		
		<cfreturn this />
	</cffunction>
	
	<!--- private methods --->
	<!------------------------------>
	
	<!--- public methods --->
	<!----------------------------->
	
	<!--- calculateBasket --->
	<cffunction  name="calculateBasket" access="public" returntype="void" output="true" description="calculate the total of the basket (according buyerType and currency)">
		<!--- calculate Session.totalBasketPrice --->
		<cfif Session.basketIndex NEQ 0>
			<cfset Session.totalBasketPrice = 0>
			<cfset Session.totalPriceInStock = 0>
			<cfset Session.totalPriceNotInStock = 0>
			<cfloop index="counter" from="1" to="#Session.basketIndex#" step="1">
				<cfset ActiveID = #Session.basket["#counter#"][1]#>
				<!--- get the packsize --->
				<cfset packsize = NumberFormat(#Application.Allproducts.products["#ActiveID#"].jcsku#, "___")>
				<!--- consumer price (consumer or sample) --->
				<cfif (Session.buyerCat EQ "consumer") OR (#Session.basket["#counter#"][2]# EQ 1 AND #Session.basket["#counter#"][2]# NEQ #packsize#)>
					<cfif Session.currency EQ "gbp">
						<cfset price = #Application.Allproducts.products["#ActiveID#"].jcpric1#>
					<cfelseif Session.currency EQ "eur">
						<cfset price = #Application.Allproducts.products["#ActiveID#"].apprice#>
					<cfelseif Session.currency EQ "usd">
						<cfset price = #Application.Allproducts.products["#ActiveID#"].usdretail#>
					</cfif>
				<!--- wholesaler price (wholesaler, AP or bulk) --->
				<cfelseif (#Session.basket["#counter#"][2]# LT packsize * 24 AND session.email NEQ "yves@joe-cool.co.uk" OR Session.buyerCat EQ "wholesaler") >
					<cfif Session.currency EQ "gbp">
						<cfset price = #Application.Allproducts.products["#ActiveID#"].jcpric2#>
					<cfelseif Session.currency EQ "eur">
						<cfset price = #Application.Allproducts.products["#ActiveID#"].eurwhlsl#>
					<cfelseif Session.currency EQ "usd">
						<cfset price = #Application.Allproducts.products["#ActiveID#"].jcnote09#>
					</cfif>
					<!--- custom selection --->
					<cfif Session.basket["#counter#"][2] MOD #packsize# NEQ 0 OR Find("_", ActiveID) NEQ 0><cfset price = #price#*120/100><cfset price = NumberFormat(#price#, "___.__")></cfif>
				<!--- bulk price --->
				<cfelse>
					<cfif Session.currency EQ "gbp">
						<cfset price = #Application.Allproducts.products["#ActiveID#"].jcpric3#>
					<cfelseif Session.currency EQ "eur">
						<cfset price = #Application.Allproducts.products["#ActiveID#"].eurbulk#>
					<cfelseif Session.currency EQ "usd">
						<cfset price = #Application.Allproducts.products["#ActiveID#"].usdbulk#>
					</cfif>
					<!--- custom selection --->
					<cfif Session.basket["#counter#"][2] MOD #packsize# NEQ 0 OR Find("_", ActiveID) NEQ 0><cfset price = #price#*120/100><cfset price = NumberFormat(#price#, "___.__")></cfif>
				</cfif>
				<!--- update totalBasketPrice --->
				<cfscript>
					quantity = #Session.basket["#counter#"][2]#;
				</cfscript>
				<cfset price = NumberFormat(#price#, "___.__")>
				<cfset Session.totalBasketPrice = #Session.totalBasketPrice#+(#price#*#quantity#)>
				<cfset Session.totalBasketPrice = NumberFormat(#Session.totalBasketPrice#, "___.__")>
				<!--- update totalPriceInStock and totalPriceNotInStock --->
				<cfif len(#Application.Allproducts.products["#ActiveID#"].jcavail#) LT 10 AND Application.Allproducts.products["#ActiveID#"].jcavail NEQ "0">
					<cfset Session.totalPriceInStock = #Session.totalPriceInStock#+(#price#*#quantity#)>
					<cfset Session.totalPriceInStock = NumberFormat(#Session.totalPriceInStock#, "___.__")>
				<cfelse>
					<cfset Session.totalPriceNotInStock = #Session.totalPriceNotInStock#+(#price#*#quantity#)>
					<cfset Session.totalPriceNotInStock = NumberFormat(#Session.totalPriceNotInStock#, "___.__")>
				</cfif>
			</cfloop>
		<cfelse>
			<cfset Session.totalBasketPrice = 0>
			<cfset Session.totalPriceInStock = 0>
			<cfset Session.totalPriceNotInStock = 0>
		</cfif>
	</cffunction>
	
	<!--- displayCust --->
	<cffunction  name="displayCust" access="public" returntype="void" output="true" description="select the right method (according buyerType and currency) of details.cfc (to display the product's thumb)">
		<cfargument name="id" required="yes" type="string">
			<cfset Session.jcid = Arguments.id>
			<!--- store the jcid in items diplayed's array --->
			<cfset Session.ItemDisplayedCodesIndex = #Session.ItemDisplayedCodesIndex# + 1>
			<cfset Session.ItemDisplayedCodes["#Session.ItemDisplayedCodesIndex#"] = #Session.jcid#>
			<cfinclude template="/EN/model/product_cust.cfm">
	</cffunction>
	
	<!--- displayPubs --->
	<cffunction  name="displayPubs" access="public" returntype="void" output="true" description="select the right method (according buyerType and currency) of details.cfc (to display the product's thumb)">
		<cfargument name="id" required="yes" type="string">
			<cfset Session.jcid = Arguments.id>
			<!--- store the jcid in items diplayed's array --->
			<cfset Session.ItemDisplayedCodesIndex = #Session.ItemDisplayedCodesIndex# + 1>
			<cfset Session.ItemDisplayedCodes["#Session.ItemDisplayedCodesIndex#"] = #Session.jcid#>
			<cfinclude template="/EN/model/product_pub.cfm">
	</cffunction>
	
	<!--- displayThumbs --->
	<cffunction  name="displayThumbs" access="public" returntype="void" output="true" description="select the right method (according buyerType and currency) of details.cfc (to display the product's thumb)">
		<cfargument name="id" required="yes" type="string">
			<cfset Session.jcid = Arguments.id>
			<!--- store the jcid in items diplayed's array --->
			<cfset Session.ItemDisplayedCodesIndex = #Session.ItemDisplayedCodesIndex# + 1>
			<cfset Session.ItemDisplayedCodes["#Session.ItemDisplayedCodesIndex#"] = #Session.jcid#>
			<cfinclude template="/EN/model/product_thumb.cfm">
	</cffunction>
	
	<!--- displayDetails --->
	<cffunction  name="displayDetails" access="public" returntype="void" output="true" description="select the right method (according buyerType and currency) of details.cfc (to display the product's details page)">
		<cfargument name="id" required="yes" type="string">
			<cfset Session.jcid = Arguments.id>
			<!--- store the jcid in items diplayed's array --->
			<cfset Session.ItemDisplayedCodesIndex = #Session.ItemDisplayedCodesIndex# + 1>
			<cfset Session.ItemDisplayedCodes["#Session.ItemDisplayedCodesIndex#"] = #Session.jcid#>
			<cfinclude template="/EN/model/product_details.cfm">
	</cffunction>
	
	<!--- displayBasket --->
	<cffunction  name="displayBasket" access="public" returntype="void" output="true" description="select the right method (according buyerType and currency) of shopping_basket.cfc (to display the product's details page)">
		<cfargument name="id" required="yes" type="string">
			<cfset Session.jcid = Arguments.id>
			<!--- store the jcid in items diplayed's array --->
			<cfset Session.ItemDisplayedCodesIndex = #Session.ItemDisplayedCodesIndex# + 1>
			<cfset Session.ItemDisplayedCodes["#Session.ItemDisplayedCodesIndex#"] = #Session.jcid#>
			<cfinclude template="/EN/model/product_basket.cfm">
	</cffunction>
	
	<!--- displayBill --->
	<cffunction  name="displayBill" access="public" returntype="void" output="true" description="select the right method (according buyerType and currency) of order_confirmed.cfc (to display the product's details page)">
		<cfargument name="id" required="yes" type="string">
			<cfset Session.jcid = Arguments.id>
			<!--- store the jcid in items diplayed's array --->
			<cfset Session.ItemDisplayedCodesIndex = #Session.ItemDisplayedCodesIndex# + 1>
			<cfset Session.ItemDisplayedCodes["#Session.ItemDisplayedCodesIndex#"] = #Session.jcid#>
			<cfinclude template="/EN/model/product_bill.cfm">
	</cffunction>
</cfcomponent>

Open in new window



And then component that translate the query in to a structure :

<cfcomponent name="queryTool" hint="Transforms a query into other data types." output="false">

<!--- Public queryTool init() --->
<cffunction output="false" access="public" returnType="queryTool" name="init">
  <cfargument name="inQuery" type="query" required="true" hint="The query to transform."/>
  <cfset variables.instance = structNew() />
  <cfset variables.instance.inQuery = arguments.inQuery>
  <cfreturn this />
</cffunction>

<!--- Public Array toArray(query inQuery) --->
<cffunction output="false" access="public" returnType="array" name="toArray" hint="Transforms a query into an array of structures.">
  <cfset var result = arrayNew(1) />
  <cfset var row = structNew() />
  <cfset var i = "" />
  
  <cfloop query="variables.instance.inQuery">
    <cfset row = structNew() />
    <cfloop list="#variables.instance.inQuery.columnList#" index="i">
      <cfset row[i] = variables.instance.inQuery[i][variables.instance.inQuery.currentRow] />
    </cfloop>
    <cfset arrayAppend(result, row) />
  </cfloop>
  
  <cfreturn result />
</cffunction>

<!--- Public Struct toStruct(query inQuery, string primaryKey) --->
<cffunction output="false" access="public" returnType="struct" name="toStruct" hint="Transforms a query into a structure, using a designated column as the key.">
  <cfargument name="primaryKey" type="string" required="true" hint="The name of the column to be used as the key for the structure.  Should be a unique identifier or rows will be lost!"/>
  
  <cfset var result = structNew() />
  <cfset var row = structNew() />
  <cfset var i = "" />
  
  <cfif not listFindNoCase(variables.instance.inQuery.columnList, arguments.primaryKey)>
    <cfthrow message="The primary key passed to toStruct() is not present in your query." />
  </cfif>
  
  <cfloop query="variables.instance.inQuery">
    <cfset row = structNew() />
    <cfloop list="#variables.instance.inQuery.columnList#" index="i">
      <cfset row[i] = variables.instance.inQuery[i][variables.instance.inQuery.currentRow] />
    </cfloop>
    <cfset result[variables.instance.inQuery[arguments.primaryKey][variables.instance.inQuery.currentRow]] = row />
  </cfloop>
  
  <cfreturn result />
</cffunction>

<!--- Public Struct toStruct(query inQuery, string primaryKey) --->
<cffunction output="false" access="public" returnType="struct" name="toStructAsc" hint="Transforms a query into a structure, using a designated column as the key.">
  <cfargument name="primaryKey" type="string" required="true" hint="The name of the column to be used as the key for the structure.  Should be a unique identifier or rows will be lost!"/>
  
  <cfset var result = structNew() />
  <cfset var row = structNew() />
  <cfset var i = "" />
  
  <cfif not listFindNoCase(variables.instance.inQuery.columnList, arguments.primaryKey)>
    <cfthrow message="The primary key passed to toStruct() is not present in your query." />
  </cfif>
  
  <cfset counter = 1>
  <cfloop query="variables.instance.inQuery">
    <cfset row = structNew() />
    <cfloop list="#variables.instance.inQuery.columnList#" index="i">
      <cfset row[i] = variables.instance.inQuery[i][variables.instance.inQuery.currentRow] />
    </cfloop>
    <cfset result[counter] = row />
	<cfset counter = counter+1>
  </cfloop>
  
  <cfreturn result />
</cffunction>

<!--- Public XML toXml(query inQuery) --->
<cffunction output="false" access="public" returnType="any" name="toXml" hint="Transforms a query into an XML recordset.">
  <cfset var result = "">
  
  <cfxml variable="result">
<recordset>
  <cfloop query="variables.instance.inQuery">
    <item>
    <cfloop list="#variables.instance.inQuery.columnList#" index="i">
      <cfoutput><#i#>#variables.instance.inQuery[i][variables.instance.inQuery.currentRow]#</#i#></cfoutput>
    </cfloop>
    </item>
  </cfloop>
</recordset>
  </cfxml>
  
  <cfreturn result>
</cffunction>

<!--- Public XML toDelimited(query inQuery) --->
<cffunction output="false" access="public" returnType="string" name="toDelimited" hint="Transforms a query into a delimited string using the given delimiter and linefeed characters.">
  <cfargument name="delimiter" type="string" default="#chr(9)#" hint="Default column delimiter (default is TAB)."/>
  <cfargument name="linefeed" type="string" default="#chr(10)#" hint="Default linefeed (default is chr(10))."/>

  <cfset var result = "">

  <cfloop list="#variables.instance.inQuery.columnList#" index="i">
    <cfset result = result & "#trim(i)#">
    <cfif i eq listGetAt(variables.instance.inQuery.columnList, listLen(variables.instance.inQuery.columnList))>
      <cfset result = result & arguments.lineFeed>
    <cfelse>
      <cfset result = result & arguments.delimiter>
    </cfif>
  </cfloop>
  <cfloop query="variables.instance.inQuery">
    <cfloop list="#variables.instance.inQuery.columnList#" index="i">
      <cfset result = result & "#variables.instance.inQuery[i][variables.instance.inQuery.currentRow]#">
      <cfif i eq listGetAt(variables.instance.inQuery.columnList, listLen(variables.instance.inQuery.columnList))>
        <cfset result = result & arguments.lineFeed>
      <cfelse>
        <cfset result = result & arguments.delimiter>
      </cfif>
    </cfloop>
  </cfloop>
  <cfreturn result>
</cffunction>
</cfcomponent>

Open in new window


I hope this help solving this case.

MANY THANKS !
Adam
0
 

Author Comment

by:adam1h
ID: 39888234
Hi There,

We have deleted a lot of queries at our end, and hardcoded instead to avoid long loading times.

Eventhough a lot of pages are much quicker, the 'bracelets', 'necklaces' and so on are still very long to load (over 30 seconds).

There more there is products to display, the longer it is.

WE dearly hope to find some hope from you guys...THANKS !
Adam
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 24

Expert Comment

by:dgrafx
ID: 39888565
post exactly what you are using now.
it sounds you like you still have some of the multiple query issues.

plus one thing i'd like to know that you didn't answer.
immediately after your CFQuery code place a variable that tells us what the query recordcount is - #queryname.recordcount#.

agx has done a lot of work on this and so he'll probably have additional insights.
0
 

Author Comment

by:adam1h
ID: 39888733
Hi,

Just a little precision before : #queryname.recordcount# is just the number of lines the query return. By default it’s 20 (= the number of products displayed).

I will post now all the process for a page, for instance the page to display bracelets.

First of all, it start with application.cfc :
<!--- onRequestStart --->
	<cffunction name="onRequestStart" returnType="boolean">
		<cfargument type="String" name="targetPage" required="yes" />
			<!--- check if user is remembered (by cookie) --->
            <cfif Session.loggedIn EQ "no" AND IsDefined("cookie.User_email") AND IsDefined("cookie.User_password")>
                <!---- Get User's info based on db ------>
                <cfquery name="qVerify" datasource="joecool_web">
                    select *
                    from webAccounts
                    where email = '<cfoutput>#Cookie.User_email#</cfoutput>'
                    and password = '<cfoutput>#Cookie.User_password#</cfoutput>'
                </cfquery>
                
                <!---- If the recordcount is 0, the login info is invalid --->
                <cfif qVerify.recordcount GTE 1>
                    <!--- This user has logged in correctly --->
                    <cfif qVerify.buyerCategory EQ "Extra 1">
                        <cfset session.buyerCat = "wholesaler">
                    <cfelseif qVerify.buyerCategory EQ "Extra 2">
                        <cfset session.buyerCat = "AP">
                    <cfelseif qVerify.buyerCategory EQ "Extra 3">
                        <cfset session.buyerCat = "AP">
                    <cfelseif qVerify.buyerCategory EQ "Extra 7">
                        <cfset session.buyerCat = "bulk">
                    <cfelseif qVerify.buyerCategory EQ "Extra 8">
                        <cfset session.buyerCat = "wholesaler">
                    <cfelseif qVerify.buyerCategory EQ "Extra 9">
                        <cfset session.buyerCat = "bulk">
                    <cfelseif qVerify.buyerCategory EQ "consumer">
                        <cfset session.buyerCat = "consumer">
                    <cfelseif qVerify.buyerCategory EQ "wholesaler">
                        <cfset session.buyerCat = "wholesaler">
                    <cfelseif qVerify.buyerCategory EQ "bulk">
                        <cfset session.buyerCat = "bulk">
                    <cfelseif qVerify.buyerCategory EQ "AP">
                        <cfset session.buyerCat = "AP">
                    <cfelseif qVerify.buyerCategory EQ "Trade">
                        <cfset session.buyerCat = "wholesaler">
                    <cfelseif findNoCase("shop", qVerify.buyerCategory)>
                        <cfset session.buyerCat = "consumer">
                    <cfelseif findNoCase("bulk", qVerify.buyerCategory)>
                        <cfset session.buyerCat = "bulk">
                    <cfelseif findNoCase("whls", qVerify.buyerCategory)>
                        <cfset session.buyerCat = "wholesaler">
                    <cfelseif findNoCase("retl", qVerify.buyerCategory)>
                        <cfset session.buyerCat = "wholesaler">
	  	    <cfelseif findNoCase("con j", qVerify.category)>
			<cfset session.buyerCat = "consumer">
	  	    <cfelse>
			<cfset session.buyerCat = "wholesaler">
	  	    </cfif>
                    
                    <cfset Session.ADDRESS_1 = "#qVerify.ADDRESS_1#">
                    <cfset Session.ADDRESS_2 = "">
                    <cfset Session.businessName = "#qVerify.businessName#">
                    <cfset Session.country = "#qVerify.country#">
                    <cfset Session.email = "#qVerify.email#">
                    <cfset Session.fax = "#qVerify.fax#">
                    <cfset Session.name = "#qVerify.name#">
                    <cfset Session.phone = "#qVerify.phone#">
                    <cfset Session.password = "#qVerify.password#">
                    <cfset Session.POST_CODE = "#qVerify.POST_CODE#">
                    <cfset Session.STATE = "#qVerify.STATE#">
                    <cfset Session.TOWN = "#qVerify.TOWN#">
                    <cfset Session.vat = "#qVerify.vat#">
                    <cfset Session.VALIDCC = "#qVerify.VALIDCC#">
                    <cfset session.loggedIn = "yes">
                    <cfif session.email EQ [quote]...test if it’s an admin account’s email...[/quote]>
                        <cfset Session.isAdmin = "yes">
                    </cfif>
                    
                    <cfquery name="getCarriage" datasource="joecool_web">
                        SELECT		currency
                        FROM		jccarriage
                        WHERE		carriage_id = '#session.country#'
                    </cfquery>
                    <cfif getCarriage.RecordCount>
                        <cfset Session.currency = #getCarriage.currency#>
                    <cfelse>
                        <cfset Session.currency = 'usd'>
                        <cfset Session.country = 'world'>
                    </cfif>
	
	
					<cfquery name="cleanBasket" datasource="joecool_web">
						DELETE FROM customers_basket where basket_1_jcid not in (select jcid from jcstktabl)
					</cfquery>
					<cfquery name="basket" datasource="joecool_web">
						select * from customers_basket 
							where <cfoutput> password like '#Session.password#' and email like '#Session.email#'</cfoutput>
					</cfquery>
					<cfif basket.RecordCount>
						<cfset Session.basketIndex = 0>
						<cfloop query="basket">
							<cfset Session.basketIndex = Session.basketIndex + 1>
							<cfset Session.basket["#Session.basketIndex#"][1] = "#basket.basket_1_jcid#"><!--- [1]=jcid --->
							<cfset Session.basket["#Session.basketIndex#"][2] = "#basket.basket_2_qty#"><!--- [2]=qty --->
							<cfset Session.basket["#Session.basketIndex#"][3] = "#basket.basket_3_color#"><!--- [3]=color --->
							<cfset Session.basket["#Session.basketIndex#"][4] = "#basket.basket_4_size#"><!--- [4]=size --->
						</cfloop>
					</cfif>
                </cfif>
            </cfif>
            	
		<cfreturn True>

Open in new window


<!--- onRequest --->
	<cffunction name="onRequest" returnType="void" output="yes">
		<cfargument name="targetPage" type="String" required="yes" default="index.html" />	
			<cfoutput>
<cfif Arguments.targetPage NEQ '/EN/basket/shopping_basket.cfm'>
	<cfheader name="Expires" value="Fri, 01 Jan 2000 00:00:00 GMT" />
	<cfheader name="Pragma" value="no-cache" />
	<cfheader name="cache-control" value="no-cache, no-store, must-revalidate" />
</cfif>
	
		<link href="/joecoolstyles.css" rel="stylesheet" type="text/css" />
				
				<cfset Session.targetP = "#Arguments.targetPage#">
				<!--- include topbuts --->
				<cfif #Arguments.targetPage# NEQ "/EN/tellafriend/tellafriendform.cfm" 
					AND #Arguments.targetPage# NEQ "/index.cfm" 
					AND #Arguments.targetPage# NEQ "/indexNEW.cfm"
					AND #Arguments.targetPage# NEQ "/EN/search.cfm"
					AND #Arguments.targetPage# NEQ "/asad_update.cfm">
					<cfinclude template="/EN/topbuts.cfm">
				</cfif>
				
				<!--- include the called page --->
				<cfparam name="Application.updating" default="false">
				<cfif Application.updating EQ true AND Find("jcadmin", Arguments.targetPage) EQ 0>
					<cfset local.timeEndEstimated = dateAdd("n", 20, Application.updatingStartTime)>
					<cfset local.timeLeft = dateDiff("n", now(), local.timeEndEstimated)>
					<cfif local.timeLeft GT 1>
						<table align="center"> <tr> <td>
							<h1>The website is currently updating</h1>
							<h2>Please try again in a few minutes (estimated time left : #local.timeLeft# minutes maximum).</h2>
							<h2>Thanks. The Joe Cool (uk) ltd Team.</h2>
						</td> </tr> </table>
					<cfelseif local.timeLeft GT -1>
						<table align="center"> <tr> <td>
							<h1>The website is currently updating</h1>
							<h2>Please try again in a few minutes (estimated time left : 1 minute).</h2>
							<h2>Thanks. The Joe Cool (uk) ltd Team.</h2>
						</td> </tr> </table>
					<cfelse>
						<cfset Application.updating = false>
						<cfinclude template="#Arguments.targetPage#">
					</cfif>
				<cfelse>
					<cfinclude template="#Arguments.targetPage#">
				</cfif>

				<!--- include footer --->
				<cfif #Arguments.targetPage# NEQ "/index.cfm" 
					AND #Arguments.targetPage# NEQ "/EN/home/home.cfm">
						<cfinclude template="/EN/footer.cfm">
    				</cfif>
			</cfoutput>
    </cffunction>

Open in new window


Now the first inserted part : topbuts.cfm (the top banner) :
<!--[if (gte IE 6)&(lte IE 8)]>
  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<![endif]-->

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<cfparam name="Session.sortby" default="highestPrice">
<cfparam name="Session.page" default="1">
<cfparam name="Session.ItemDisplayed" default="12">
<cfif Session.ItemDisplayed EQ ""><cfset Session.ItemDisplayed = 50></cfif>
<script type="text/javascript" src="/jquery-1.4.4.min.js"></script>

<script type="text/javascript" src="/jquery.jqzoom1.0.1.js"></script>
<script type="text/javascript">
	$(document).ready(function(){var options = {zoomWidth: 300, zoomHeight: 300, xOffset: 10, yOffset: 0, position: "right"};
	$('.thisjqzoom').jqzoom(options);
});
</script>
<script type="text/javascript" src="//assets.pinterest.com/js/pinit.js"></script>

<cfset thisBasketValue = "#session.totalBasketPrice# #session.currency#">
<link rel="stylesheet" href="/EN/dropmenu_files/style.css" type="text/css" />
<style type="text/css">
a:link {
	color: #000033;
}
a:hover {
	color: #000099;
}
a:visited {
	color: #000033;
}
html {
  filter: expression(document.execCommand("BackgroundImageCache", false, true));
}
.texta {
 font-size: 10px;
 background-color: #FFFFF;
 border: 1px solid #666666;
}
	a img {border:none}
}
</style>

</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
	<table width="900" align="center">
  <cfif Session.isAdmin EQ "yes">
	<tr>
		<td width="103" height="37" align="left" valign="top" class="Informal_text_dynamic">
		  <a onClick="processing()" href="https://<cfoutput>#CGI.server_name#</cfoutput>/jcadmin/home.cfm" class="pagination">&#9632; Admin Home</a></td>
		<td width="126" align="left" valign="top" class="Informal_text_dynamic">
		  <a onClick="processing()" href="https://<cfoutput>#CGI.server_name#</cfoutput>/jcadmin/newsletters.cfm?step=select&id=0" class="Informal_text_dynamic">&#9632; Newsletters Tool</a>		</td>
	  <td width="148" align="left" valign="top">
	    <a onClick="processing()" href="/News_Database/index.cfm" class="Informal_text_dynamic">&#9632; Newsletters MODULE</a>		</td>
		<td width="255" align="left" valign="top" class="links_prev_next">
		  <a onClick="processing()" href="https://<cfoutput>#CGI.server_name#</cfoutput>/jcadmin/editMode_switch.cfm?previous=<cfoutput>#urlEncodedFormat(CGI.Script_Name &  "?" & CGI.Query_String)#</cfoutput>" class="Informal_text_dynamic">&#9632; Switch to 
        <cfif Session.isEditMode EQ "no">Edition<cfelse>Normal</cfif> Mode</a>		</td>
		<td width="194" align="left" valign="top" class="links_prev_next">
		<a onclick="processing()" href="https://<cfoutput>#CGI.server_name#</cfoutput>/jcadmin/editMode_validate.cfm?action=validate" class="Informal_text_dynamic"><cfif Session.isEditMode EQ "yes">&#9632; Validate Changes Done</a></cfif></td>
		<td width="91" align="left" valign="top" nowrap class="Informal_text_dynamic">
			<a onClick="processing()" href="https://<cfoutput>#CGI.server_name#</cfoutput>/jcadmin/Vince/NewTask.cfm" class="Informal_text_dynamic"><!---&#9632; New Task---></a></td>
	</tr>
  </cfif>
</table>
<table width="900" border="0" align="center">
  <tr>
    <td width="218"  align="left" valign="top">
    
    <ul onMouseOut="JavaScript:hideAll();" class="navPreviousPages">
    <li><!---class="topfirst homelogo"--->
            <a onClick="processing()" href="/EN/home/home.cfm" onMouseOver="visibilite('homelogomenu');"><img src="/graphics/joecoollogotopbuts.png" alt="Joe Cool UK Ltd, wholesale, retail and distribution in fashion jewellery since 1978" width="190" height="73" id="rollover" ></a>
            <ul id="homelogomenu">
            <li class="subfirst"><a onClick="processing()" href="/EN/home/home.cfm">Home</a>
                        <li><a onClick="processing()" href="/EN/terms/terms.cfm">Terms of trade</a></li>
                        <li><a onClick="processing()" href="/EN/contacts/contacts.cfm">Contacts</a></li>
                        <li><a onClick="processing()" href="/EN/aboutus/aboutus.cfm">About us</a></li>
                        <li><cfif Session.loggedIn EQ "yes" AND session.buyerCat NEQ "consumer">
        &nbsp;&nbsp;&nbsp;<a onClick="processing()" href="/EN/showdates/showdates.cfm">Trade show dates</a>
      <cfelse>
        &nbsp;&nbsp;&nbsp;<a onClick="processing()" href="/EN/showdates/festivals.cfm" ><cfoutput>Festivals</cfoutput></a>
        </cfif></li>
					
			</ul>
            </li>
            </ul>
      </td>
    <td width="239" align="right" valign="top">
    <table width="228" align="right">
        <tr>
          <td width="220" colspan="9" align="right" valign="top"></td>
        </tr>
        <tr>
          <td colspan="9" align="right" valign="top" class="Informal_text_dynamic"></td>
        </tr>
         <tr align="right" valign="top">
            <td height="23" colspan="9" align="left" valign="middle" class="Informal_text_non_dynamic_turq"><span class="Informal_text_dynamic">Currency :&nbsp;</span>              <select name="country2" onChange="document.location.href='/EN/currency/country.cfm'+this.options[this.options.selectedIndex].value">
              <cfif Session.currency IS "eur">
                <option value="?cur=eur" selected="selected">&euro;</option>
                <cfelse>
                <option value="?cur=eur">&euro;</option>
                </cfif>
              <cfif Session.currency IS "gbp">
                <option value="?cur=gbp"  selected="selected">&pound;</option>
                <cfelse>
                <option value="?cur=gbp">&pound;</option>
                </cfif>
              <cfif Session.currency IS "usd">
                <option value="?cur=usd"  selected="selected">$US</option>
                <cfelse>
                <option value="?cur=usd">$US</option>
                </cfif>
            </select></td>
          </tr>
          <tr align="right" valign="top">
            <td height="31" colspan="9" align="left" valign="middle" class="Informal_text_non_dynamic_turq">
            <!---<cfif session.email eq "yves@joe-cool.co.uk" or session.email eq "vincent@joe-cool.co.uk">--->
					<a onClick="processing()" href="/EN/currency/language.cfm?lang=en"><img src="/graphics/flagEn.png" /></a>
					<a onClick="processing()" href="/EN/currency/language.cfm?lang=fr"><img src="/graphics/flagFr.png" /></a>
					<a onClick="processing()" href="/EN/currency/language.cfm?lang=es"><img src="/graphics/flagSp.png" /></a>
					<a onClick="processing()" href="/EN/currency/language.cfm?lang=it"><img src="/graphics/flagIt.png" /></a>
					<a onClick="processing()" href="/EN/currency/language.cfm?lang=ge"><img src="/graphics/flagGe.png" /></a>
				<!---</cfif>--->
                </td>
          </tr>
          <tr align="right" valign="top">
            <td height="31" colspan="9" align="left" valign="middle" class="Informal_text_non_dynamic_turq">
            
    </td>
          </tr>
<td width="429" align="right" valign="top">
<cfoutput>
      <cfif Session.loggedIn EQ "yes">
<span class="links_prev_next">Logged in as</span><span class="collection_title">&nbsp;#Session.email#&nbsp;</span><span class="links_prev_next">&nbsp;I&nbsp;&nbsp; <a onClick="processing()" href="https://#CGI.server_name#/EN/mydetails/mydetails.cfm" class="links_prev_next"> My Details</a>&nbsp;&nbsp;I&nbsp;&nbsp;<a onClick="processing()" href="https://#CGI.server_name#/EN/mydetails/myPreviousOrders.cfm"> My order history</a>&nbsp;&nbsp;I&nbsp;&nbsp; </span><a onClick="processing()" href="https://www.joe-cool.co.uk/EN/logout/logout.cfm" class="links_prev_next">Logout</a></span>
        <!---onclick="return confirm('Your basket will be deleted. Do you wish to continue ?');"--->
        <cfelse>
        <a onClick="processing()" href="https://www.joe-cool.co.uk/EN/login/new_login_consumer.cfm"><span class="links_prev_next">Register&nbsp;I&nbsp;</span></a> <a onClick="processing()" href="https://www.joe-cool.co.uk/EN/login/new_login_trade.cfm"><span class="backgroudavert1"><span class="links_prev_next">Trade Register</span></span></a><span class="backgroudavert1">&nbsp;I&nbsp; <a onClick="processing()" href="https://www.joe-cool.co.uk/EN/login/loginForgotten.cfm"><span class=" links_prev_next">Forgotten Password</span></a>&nbsp;I&nbsp; <a onClick="processing()" href="https://www.joe-cool.co.uk/index.cfm"><span class=" links_prev_next">Login</span></a> </span>
      </cfif>
    </cfoutput>
	
<!---<cfquery name="itemsInBasket" dbtype="query">
	select active from contents where pages_id = 'topbuts_itemsInBasket'
</cfquery>--->
	<cfoutput>
      <cfif Session.basketIndex GT 0 <!---AND #targetPage# NEQ '/EN/basket/shopping_basket.cfm'---> AND #targetPage# NEQ '/EN/currency/currency.cfm'>
        <cfif Session.basketIndex EQ 1>
          <cfset basketT = "#Session.basketIndex# item in your basket --- Total : #session.totalBasketPrice#  #Session.currency#">
          <cfelse>
          <cfset basketT = "#Session.basketIndex# item in your basket --- Total : #session.totalBasketPrice#  #Session.currency#">
        </cfif>
        <span class="Informal_text_non_dynamic_turq">
          <div id="basketTotal">#basketT#</div>
          </span>
      </cfif>
    </cfoutput><!-- BEGIN ProvideSupport.com Pass Information Chat Button Code -->
      <div id="cia7xA" style="z-index:100;position:absolute"></div>
      <div id="sca7xA" style="display:inline"></div>
      <div id="sda7xA" style="display:none"></div>
      <script type="text/javascript">var sea7xA=document.createElement("script");sea7xA.type="text/javascript";var sea7xAs=(location.protocol.indexOf("https")==0?"https://secure.providesupport.com/image":"https://image.providesupport.com")+"/js/joecool/safe-standard.js?ps_h=a7xA\u0026ps_t="+new Date().getTime()+"\u0026Type=<cfoutput>#session.buyerCat#</cfoutput>\u0026Email=<cfoutput>#session.email#</cfoutput>\u0026Password=<cfoutput>#session.password#</cfoutput>\u0026Items=<cfoutput>#session.basketIndex#</cfoutput>\u0026Value=<cfoutput>#thisBasketValue#</cfoutput>";setTimeout("sea7xA.src=sea7xAs;document.getElementById('sda7xA').appendChild(sea7xA)",1)</script>
	  
<!---<cfquery name="custService" dbtype="query">
	select active from contents where pages_id = 'topbuts_custService'
</cfquery>--->
      <noscript>
      <div style="display:inline"><a onClick="processing()" href="https://www.providesupport.com?messenger=joecool">Online Customer Service</a></div>
      </noscript>
      <!-- END ProvideSupport.com Pass Information Chat Button Code -->
    <cfif Session.basketIndex GT 0>
      
<!---<cfquery name="ccAccepted" dbtype="query">
	select active from contents where pages_id = 'topbuts_ccAccepted'
</cfquery>---><table width="124" align="right"><tr><td width="65" height="34" align="left" valign="top"><img src="https://<cfoutput>#CGI.server_name#</cfoutput>/EN/graphics/shoppingbag.jpg" alt="I want to check my basket" title="I want to check my basket" width="28" height="32" border="0" align="right" usemap="#Map3Map" />
                      <map name="Map3Map" id="Map3Map">
                        <area onClick="processing()" shape="rect" coords="-3,2,39,62" href="https://<cfoutput>#CGI.server_name#</cfoutput>/EN/basket/shopping_basket.cfm" />
                    </map></td>
					
<!---<cfquery name="checkout" dbtype="query">
	select active from contents where pages_id = 'topbuts_checkout'
</cfquery>--->
                    <td width="73" align="right" valign="top"><img src="https://<cfoutput>#CGI.server_name#</cfoutput>/EN/graphics/checkout.jpg" alt="Checkout Process my Joe Cool Order" width="32" height="32" border="0" align="right" usemap="#Map" />
                      <map name="Map" id="Map">
                        <area onClick="processing()" shape="rect" coords="0,0,66,59" href="/EN/basket/checkout.cfm" target="_self" alt="Checkout" title="Checkout" />
            </map></td>
                    
                  </tr>
  <tr>
    <td height="20" align="center" valign="top" class="links_prev_next">Basket</td>
    <td align="right" valign="top" class="links_prev_next">Checkout</td>
  </tr>
    </table>
   </cfif>  
<!---</td>
  </tr>--->
</table>
<table width="900" border="0" align="center">
	<td valign="top"><cfinclude template="/EN/dropmenu.cfm"></td>
	</tr>
</table>

Open in new window


Now the page called (the bracelets one) :
<cfscript>Variables.pageNow = CreateObject("component", "Application").addTitle(cat="#url.catname#", rng="#url.rngname#", mode=0); activePage = url.page;</cfscript>
<title><cfoutput>#Variables.pageNow#</cfoutput></title>

<!--- create an instance of product.cfc --->
<cfparam name="Session.inStockOnly" default="no">
<cfif IsDefined("url.inStockOnly")><cfset Session.inStockOnly = url.inStockOnly></cfif>
  <cfscript>
	products_instance = CreateObject("component", "products_results").init(range="#url.rngname#", cat="#url.catname#", sortby="#url.sortby#", inStockOnly="#Session.inStockOnly#", itemsPerPages="#url.items#", page="#url.page#");
  </cfscript>
  
 
<!--- navlinks & sorting and filters --->
<table width="900" align="center">
  <tr>
    <td class="Informal_text_dynamic">
		<cfscript>
			Variables.urlNow = "#CGI.Script_Name#" &  "?" & "#CGI.Query_String#";
			CreateObject("component", "Application").addNavLinks(page="#Variables.pageNow#", url="#Variables.urlNow#", thumbsPage=#url.page#);
		</cfscript>
	</td>
  </tr>
  <tr>
  	<td class="Informal_text_dynamic">
		<cfset numberItems = products_instance.totalItems>
		<cfscript>CreateObject("component", "Application").addThumbsSortAndFilter(cat="#url.catname#", rng="#url.rngname#", itemsPerPages="#url.items#", itemsTotal="#numberItems#", page="#url.page#", sortby="#url.sortby#", mode=0);</cfscript>
	</td>
  </tr>
</table>
  
  
  
<!--- display data (thumbs) --->
<table width="900" align="center">
  <cfif products_instance.results.RecordCount EQ 0><tr><td width="900" align="center" valign="middle">Sorry, no products for this category now</td></tr></cfif>
  <!---<cfif StructCount(products_instance.results) EQ 0><tr><td width="900" align="center" valign="middle">Sorry, no products for this category now</td></tr></cfif>--->

  <cfset displayCounter = 0>
  <cfset counter = 0>
  <cfloop query="products_instance.results">
  <!---<cfloop index="counter" from="1" to="#Session.ItemDisplayed#" step="1">--->
	  <cftry>
		  <cfsavecontent variable="thumb">
			  <cfoutput>
				<cfset counter ++>
				<cfset displayCounter ++>
				<cfif displayCounter EQ 4>
					<cfset displayCounter = 1>
				</cfif>
				<cfif displayCounter EQ 1>
					<tr>
				</cfif>
				<td width="300" align="center" valign="middle">
					<!---<cfset i = products_instance.results["#counter#"].jcid>
					<cfinvoke component="#Application.Allproducts#" method="displayThumbs" id="#i#">--->
					<cfinvoke component="#Application.Allproducts#" method="displayThumbs" id="#jcid#">
				</td>
				<cfif counter EQ #Session.ItemDisplayed# >
					<cfif displayCounter EQ 1>
						<td width="300" align="center" valign="middle">&nbsp;</td>
						<td width="300" align="center" valign="middle">&nbsp;</td>
					<cfelseif displayCounter EQ 2>
						<td width="300" align="center" valign="middle">&nbsp;</td>
					</cfif>
					<cfset displayCounter = 3>
				</cfif>
				<cfif displayCounter EQ 3>
					</tr>
				</cfif>
			  </cfoutput>
		  </cfsavecontent>
		  <cfoutput>#thumb#</cfoutput>
	  <cfcatch type="any"><cfset displayCounter -- ></cfcatch>
	  </cftry>
  </cfloop>
  </table>
  
<!--- navlinks & sorting and filters --->
<table width="900" align="center">
  <tr>
    <td class="Informal_text_dynamic">
		<cfscript>
			Variables.urlNow = "#CGI.Script_Name#" &  "?" & "#CGI.Query_String#";
			CreateObject("component", "Application").addNavLinks(page="#Variables.pageNow#", url="#Variables.urlNow#", thumbs=false);
		</cfscript>
	</td>
  </tr>
  <tr>
  	<td class="Informal_text_dynamic">
		<cfset numberItems = products_instance.totalItems>
		<cfscript>CreateObject("component", "Application").addThumbsSortAndFilter(cat="#url.catname#", rng="#url.rngname#", itemsPerPages="#url.items#", itemsTotal="#numberItems#", page="#url.page#", sortby="#url.sortby#", mode=0);</cfscript>
	</td>
  </tr>
</table>

Open in new window


and the corresponding called products_results.cfc :
	<cfcomponent displayname="products_results">
	<!--- fields --->
	<!-------------->
	<cfset This.rngname = "">
	<cfset This.catname = "">
	<!---<cfset This.results = StructNew()> ---> 
	<cfset This.totalItems = 0>
	
	<!--- init method --->
	<!------------------->
	<cffunction name="init" access="public" output="true" returntype="products_results">
		<cfargument name="range" required="yes" type="string">
		<cfargument name="cat" required="yes" type="string">
		<cfargument name="sortby" required="yes" type="string" default="highestPrice">
		<cfargument name="itemsPerPages" required="yes" type="string">
		<cfargument name="page" required="yes" type="string">
		<cfargument name="inStockOnly" required="no" type="string" default="no">
			
			<!--- collect range and cat --->
			<cfset This.rngname = Arguments.range>
			<cfset This.catname = Arguments.cat>
			<cfset This.sortbyname = Arguments.sortby>
			
			<!--- set the right price field --->
			<cfif Session.buyerCat EQ "consumer">
				<cfif Session.currency EQ "gbp">
					<cfset priceType = "jcpric1">
				<cfelseif Session.currency EQ "eur">
					<cfset priceType = "apprice">
				<cfelseif Session.currency EQ "usd">
					<cfset priceType = "usdretail">
				</cfif>
			<cfelseif Session.buyerCat EQ "wholesaler" OR Session.buyerCat EQ "AP">
				<cfif Session.currency EQ "gbp">
					<cfset priceType = "jcpric2">
				<cfelseif Session.currency EQ "eur">
					<cfset priceType = "eurwhlsl">
				<cfelseif Session.currency EQ "usd">
					<cfset priceType = "jcnote09">
				</cfif>
			<cfelseif Session.buyerCat EQ "bulk">
				<cfif Session.currency EQ "gbp">
					<cfset priceType = "jcpric3">
				<cfelseif Session.currency EQ "eur">
					<cfset priceType = "eurbulk">
				<cfelseif Session.currency EQ "usd">
					<cfset priceType = "usdbulk">
				</cfif>
			</cfif>
			
			<cfif Arguments.cat EQ "All necklaces">
				<cfset This.catname = "jccatname like 'necklace' or jccatname like 'necklace long' or jccatname like 'Necklace choker' or jccatname like 'Necklace chain' or jccatname like 'Necklace & bracelet set' or jccatname like 'Necklace with pendant' or jccatname like 'Pendant' ">
			<cfelseif Arguments.cat EQ "All bracelets">
				<cfset This.catname = "jccatname like 'Bracelet' or jccatname like 'Bangle' or jccatname like 'Bracelet  or anklet' ">
			<cfelseif Arguments.cat EQ "All rings">
				<cfset This.catname = "jccatname like 'Ring' or jccatname like 'Ring for toes' or jccatname like 'Ring for thumbs' ">
			<cfelseif Arguments.cat EQ "All accessories">
				<cfset This.catname = "jccatname like 'Purse' or jccatname like 'Belt' or jccatname like 'Bag' or jccatname like 'Scarves' or jccatname like 'Keyring' or jccatname like 'Tattoos' or jccatname like 'Jewellery box' or jccatname like 'Magnet' or jccatname like 'Wrist watch' or jccatname like 'Brooch' or jccatname like 'Clutch pin' or jccatname like 'Handbag Charm' or jccatname like 'Zip pull' ">
			<cfelseif Arguments.cat EQ "All earrings">
				<cfset This.catname = "jccatname like 'Earring drop' or jccatname like 'Earring stud' or jccatname like 'Earring hoop' or jccatname like 'Earring pin' or jccatname like 'Earring stud  drop' or jccatname like 'Earring clip' ">
			<cfelseif Arguments.cat EQ "All body jewellery">
				<cfset This.catname = "jccatname like 'Body jewellery' or jccatname like 'Belly jewellery' or jccatname like 'Nose stud' or jccatname like 'Nose' ">
			<cfelseif Arguments.cat EQ "All hairwear">
				<cfset This.catname = "jccatname like 'Hairwear' or jccatname like 'Hairpin' ">
			<cfelseif Arguments.cat EQ "All charms">
				<cfset This.catname = "jccatname like 'Charms' or jccatname like 'Phone charm' ">
			<cfelseif Arguments.cat EQ "All displays">
				<cfset This.catname = "jccatname like 'Display stand' or jccatname like 'Display aid' or jccatname like 'Gift packaging' ">
			<cfelseif Arguments.cat EQ "all">
				<!---<cfset This.catname = "jccatname like '%' ">---><cfset This.catname = "1 ">
			<cfelseif Arguments.cat EQ "other">
				<cfset This.catname = "jccatname like '''' ">
			<cfelseif Arguments.cat EQ "">
				<cfset This.catname = "jccatname like '''' ">
			<cfelse>
				<cfset This.catname = "jccatname like '#Arguments.cat#' ">
			</cfif>
			
			<!--- gets the results (relevent to be displayed) --->
			<cfquery name="queryFiltered" datasource="joecool_web">
				select SQL_CALC_FOUND_ROWS jcId from jcstktabl where (#REReplace(This.catname,"''","'","ALL")#) and <cfif This.rngname NEQ "all">jcmat1 = '#Arguments.range#'  and </cfif> 
				<cfif session.buyerCat EQ "consumer"> jcid not like '%COM' 
				<cfelse> jcid not like '%!_%'escape '!'
				</cfif>
				<cfif inStockOnly EQ "yes">and jcstock > '0' and jcavail not like '%-%' </cfif>
				<cfif Session.buyerCat EQ "consumer">and jccatname != 'Display stand' and jccatname != 'Display aid' and jccatname != 'Gift packaging'</cfif>
				and jcid not in (select j.jcid from oldPrices o, jcstktabl j where o.jcid = j.jcid and o.#priceType# > j.#priceType# and (100-( j.#priceType#/o.#priceType#*100)) >= 20)
				order by <cfif Arguments.sortby EQ 'novelty'>jcid desc
						<cfelseif Arguments.sortby EQ 'highestPrice'>#priceType# desc, jcid desc
						<cfelseif Arguments.sortby EQ 'lowestPrice'>#priceType# asc, jcid desc
						<cfelseif Arguments.sortby EQ 'special'>jcspoff desc, jcid desc
						<cfelseif Arguments.sortby EQ 'bestseller'>jcbestsell asc, jcid desc</cfif>
				limit #(Arguments.page-1)*Arguments.itemsPerPages#, #Arguments.itemsPerPages#
			</cfquery>
			<cfquery name="total" datasource="joecool_web">
				select FOUND_ROWS() AS total
			</cfquery>
			<cfset This.totalItems = total.total>
			
			<cfset This.results = queryFiltered>
		<cfreturn this />
	</cffunction>
</cfcomponent>

Open in new window


Now here is the part who construct one product view (product_thumb.cfm) :
<style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
}
-->
</style>

<form name="myForm" action="/EN/basket/shopping_basket.cfm" method="post">
	<cfoutput><table width="300" align="center">
	<tr><td height="200" colspan="2"  align="center" valign="top"> 
		<CFOUTPUT>
			
			<cfif Find("_", "#Session.jcid#") EQ 0>
				<cfset local.imgPathRel = "/images/thumbs/#Session.jcid#.jpg">
				<cfset local.imgPathFull = expandPath(local.imgPathRel)>
			<cfelse>
				<cfset local.imgPathRel = "/images/details_thumbs/#Session.jcid#.jpg">
				<cfset local.imgPathFull = expandPath(local.imgPathRel)>
			</cfif>
			<cftry>
				<cfimage action="info" source="#local.imgPathFull#" structname="local.img">
			<cfcatch type="Any">
				<cfset local.imgPathRel = "/images/default.jpg">
				<cfset local.imgPathFull = expandPath(local.imgPathRel)>
				<cfset local.img.height  = 200>
				<cfset local.img.width = 200>
			</cfcatch>
			</cftry>
			<cfset local.height = local.img.height>
			<cfset local.width = local.img.width>
			<cfif local.img.height GT local.img.width>
				<cfset local.height = 200>
				<cfset local.width = local.img.width / (local.img.height / 200)>
			<cfelse>
				<cfset local.height = local.img.height / (local.img.width / 200)>
				<cfset local.width = 200>
			</cfif>
			<cfset local.jccatname  = Application.Allproducts.products['#Session.jcid#'].jccatname>
			<cfset local.jcuniqdesc  = Application.Allproducts.products['#Session.jcid#'].jcuniqdesc>
			<cfset local.jcmat1  = Application.Allproducts.products["#Session.jcid#"].jcmat1>
			<img src="#local.imgPathRel#" height="#local.height#" width="#local.width#" 
				alt="&copy; Joe Cool UK Ltd fashion jewelery wholesalers #local.jccatname# #local.jcuniqdesc# in #local.jcmat1#" 	border="0"
				title="&copy; Joe Cool UK Ltd #local.jccatname# #local.jcmat1#" 
				class="MYCLASS" align="top" onclick="processing();document.location.href='/EN/details/details.cfm?jcid=#urlEncodedFormat(Session.jcid)#'" onmouseover="this.style.cursor='pointer';" />
			 
		</CFOUTPUT>
		</td>
		</tr>
				<tr><br />
				  <td colspan="2" align="center" valign="top" class="Informal_text_dynamic"><CFOUTPUT>#Application.Allproducts.products["#Session.jcid#"].jcid#</CFOUTPUT>&nbsp;<CFOUTPUT>#Application.Allproducts.products["#Session.jcid#"].jccatname#</CFOUTPUT>&nbsp;in&nbsp;<CFOUTPUT>#Application.Allproducts.products["#Session.jcid#"].jcmat1#</CFOUTPUT></td>
				</tr>
				<tr>
				  <td colspan="2" align="center" valign="top" class="Informal_text_dynamic"><CFOUTPUT>#Application.Allproducts.products["#Session.jcid#"].jcuniqdesc#</CFOUTPUT></td>
	    </tr>
       <cfoutput> <cfif #Application.Allproducts.products["#Session.jcid#"].jccollection# NEQ ""><tr>
				  <td colspan="2" align="center" valign="top" class="Informal_text_dynamic">From the collection : <span class="collection_title"><a onclick="processing()" href="/EN/search/products_results.cfm?catname=all&rngname=all&items=#urlEncodedFormat(Session.ItemDisplayed)#&page=1&sortby=#urlEncodedFormat(Session.sortBy)#&search=#urlEncodedFormat(Application.Allproducts.products['#Session.jcid#'].jccollection)#">#Application.Allproducts.products["#Session.jcid#"].jccollection#</a></span></td>
	    </tr></cfif></cfoutput>
				
				<tr>
				  <td align="center" valign="top" class="Informal_text_dynamic"></td>
				</tr>
				<!---<tr>
				  <td colspan="2" align="center" valign="top" class="Informal_text_dynamic"><span class="style16"><CFOUTPUT>#Application.Allproducts.products["#Session.jcid#"].jcuniqdesc#  <BR /> <cfif Session.buyerCat NEQ "consumer">#Application.Allproducts.products["#Session.jcid#"].jccassname#</cfif></CFOUTPUT></span></td>
				</tr>--->
				
			<!---<cfquery name="discount" dbtype="query">
	select active from contents where pages_id = 'product_details_discount'
</cfquery>--->
				<tr>
				  <td height="23" align="center" valign="top" class="thumb_title_style_bigger">
					<!--- query to store oldPrices ----------------------------------------------------------------------------------------->
					<cfquery name="oldprices" datasource="joecool_web">
						select * from oldPrices where jcid = '<cfoutput>#Application.Allproducts.products["#Session.jcid#"].jcid#</cfoutput>'
					</cfquery>
					<cfset oldPriceGreater = "no">
					<!---------------------------------------------------------------------------------------------------------------------->
					<cfif Session.currency EQ "gbp">
						<cfif Session.buyerCat EQ "consumer">
							<!--- oldPrices ------------------------------------------------------------------------->
						  <cfif #oldprices.jcpric1# GT #Application.Allproducts.products["#Session.jcid#"].jcpric1# AND (100-(#Application.Allproducts.products["#Session.jcid#"].jcpric1#/#oldprices.jcpric1#*100)) GTE 20>
							  <cfoutput><span class="oldpricetag">&pound; #oldprices.jcpric1#</span></cfoutput>
							  <cfset oldPriceGreater = "yes">
							<br />
						  </cfif>
							<!--------------------------------------------------------------------------------------->
							&pound; <cfoutput>#NumberFormat(Application.Allproducts.products["#Session.jcid#"].jcpric1, "___.__")#</cfoutput>/<cfif FindNoCase("earring", Application.Allproducts.products["#Session.jcid#"].jccatname) EQ 0>Piece<cfelse>Pair</cfif>
							<cfif #oldprices.jcpric1# GT #Application.Allproducts.products["#Session.jcid#"].jcpric1# AND (100-(#Application.Allproducts.products["#Session.jcid#"].jcpric1#/#oldprices.jcpric1#*100)) GTE 20>
								<br />
								<cfset x = 100-(#Application.Allproducts.products["#Session.jcid#"].jcpric1#/#oldprices.jcpric1#*100)>
								<cfoutput><span class="product_links">#NumberFormat(x, "___")#% Discount</span></cfoutput>
							</cfif>
						<cfelseif Session.buyerCat EQ "wholesaler" OR Session.buyerCat EQ "AP">
							<!--- oldPrices ------------------------------------------------------------------------->
						  <cfif #oldprices.jcpric2# GT #Application.Allproducts.products["#Session.jcid#"].jcpric2# AND (100-(#Application.Allproducts.products["#Session.jcid#"].jcpric2#/#oldprices.jcpric2#*100)) GTE 20>
							  <cfoutput><span class="oldpricetag">&pound; #oldprices.jcpric2#</span></cfoutput>
							  <cfset oldPriceGreater = "yes">
							<br />
						  </cfif>
							<!--------------------------------------------------------------------------------------->
							&pound; <cfoutput>#NumberFormat(Application.Allproducts.products["#Session.jcid#"].jcpric2, "___.__")#</cfoutput>/<cfif FindNoCase("earring", Application.Allproducts.products["#Session.jcid#"].jccatname) EQ 0>Piece<cfelse>Pair</cfif>
							<cfif #oldprices.jcpric2# GT #Application.Allproducts.products["#Session.jcid#"].jcpric2# AND (100-(#Application.Allproducts.products["#Session.jcid#"].jcpric2#/#oldprices.jcpric2#*100)) GTE 20>
								<br />
								<cfset x = 100-(#Application.Allproducts.products["#Session.jcid#"].jcpric2#/#oldprices.jcpric2#*100)>
								<cfoutput><span class="product_links">#NumberFormat(x, "___")#% Discount</span></cfoutput>
							</cfif>
						<cfelseif Session.buyerCat EQ "bulk">
							<!--- oldPrices ------------------------------------------------------------------------->
						  <cfif #oldprices.jcpric3# GT #Application.Allproducts.products["#Session.jcid#"].jcpric3# AND (100-(#Application.Allproducts.products["#Session.jcid#"].jcpric3#/#oldprices.jcpric3#*100)) GTE 20>
							  <cfoutput><span class="oldpricetag">&pound; #oldprices.jcpric3#</span></cfoutput>
							  <cfset oldPriceGreater = "yes">
							<br />
						  </cfif>
							<!--------------------------------------------------------------------------------------->
							&pound; <cfoutput>#NumberFormat(Application.Allproducts.products["#Session.jcid#"].jcpric3, "___.__")#</cfoutput>/<cfif FindNoCase("earring", Application.Allproducts.products["#Session.jcid#"].jccatname) EQ 0>Piece<cfelse>Pair</cfif>
							<cfif #oldprices.jcpric3# GT #Application.Allproducts.products["#Session.jcid#"].jcpric3# AND (100-(#Application.Allproducts.products["#Session.jcid#"].jcpric3#/#oldprices.jcpric3#*100)) GTE 20>
								<br />
								<cfset x = 100-(#Application.Allproducts.products["#Session.jcid#"].jcpric3#/#oldprices.jcpric3#*100)>
								<cfoutput><span class="product_links">#NumberFormat(x, "___")#% Discount</span></cfoutput>
							</cfif>
						</cfif>
					<cfelseif Session.currency EQ "eur">
						<cfif Session.buyerCat EQ "consumer">
							<!--- oldPrices ------------------------------------------------------------------------->
						  <cfif #oldprices.apprice# GT #Application.Allproducts.products["#Session.jcid#"].apprice# AND (100-(#Application.Allproducts.products["#Session.jcid#"].apprice#/#oldprices.apprice#*100)) GTE 20>
							  <cfoutput><span class="oldpricetag">&euro; #oldprices.apprice#</span></cfoutput>
							  <cfset oldPriceGreater = "yes">
							<br />
						  </cfif>
							<!--------------------------------------------------------------------------------------->
							&euro; <cfoutput>#NumberFormat(Application.Allproducts.products["#Session.jcid#"].apprice, "___.__")#</cfoutput>/<cfif FindNoCase("earring", Application.Allproducts.products["#Session.jcid#"].jccatname) EQ 0>Piece<cfelse>Pair</cfif>
							<cfif #oldprices.apprice# GT #Application.Allproducts.products["#Session.jcid#"].apprice# AND (100-(#Application.Allproducts.products["#Session.jcid#"].apprice#/#oldprices.apprice#*100)) GTE 20>
								<br />
								<cfset x = 100-(#Application.Allproducts.products["#Session.jcid#"].apprice#/#oldprices.apprice#*100)>
								<cfoutput><span class="product_links">#NumberFormat(x, "___")#% Discount</span></cfoutput>
							</cfif>
						<cfelseif Session.buyerCat EQ "wholesaler" OR Session.buyerCat EQ "AP">
							<!--- oldPrices --------------------------------------------------------------------------->
						  <cfif #oldprices.eurwhlsl# GT #Application.Allproducts.products["#Session.jcid#"].eurwhlsl# AND (100-(#Application.Allproducts.products["#Session.jcid#"].eurwhlsl#/#oldprices.eurwhlsl#*100)) GTE 20>
							  <cfoutput><span class="oldpricetag">&euro; #oldprices.eurwhlsl#</span></cfoutput>
							  <cfset oldPriceGreater = "yes">
							<br />
						  </cfif>
							<!----------------------------------------------------------------------------------------->
							&euro; <cfoutput>#NumberFormat(Application.Allproducts.products["#Session.jcid#"].eurwhlsl, "___.__")#</cfoutput>/<cfif FindNoCase("earring", Application.Allproducts.products["#Session.jcid#"].jccatname) EQ 0>Piece<cfelse>Pair</cfif>
							<cfif #oldprices.eurwhlsl# GT #Application.Allproducts.products["#Session.jcid#"].eurwhlsl# AND (100-(#Application.Allproducts.products["#Session.jcid#"].eurwhlsl#/#oldprices.eurwhlsl#*100)) GTE 20>
								<br />
								<cfset x = 100-(#Application.Allproducts.products["#Session.jcid#"].eurwhlsl#/#oldprices.eurwhlsl#*100)>
								<cfoutput><span class="product_links">#NumberFormat(x, "___")#% Discount</span></cfoutput>
							</cfif>
						<cfelseif Session.buyerCat EQ "bulk">
							<!--- oldPrices ------------------------------------------------------------------------->
						  <cfif #oldprices.eurbulk# GT #Application.Allproducts.products["#Session.jcid#"].eurbulk# AND (100-(#Application.Allproducts.products["#Session.jcid#"].eurbulk#/#oldprices.eurbulk#*100)) GTE 20>
							  <cfoutput><span class="oldpricetag">&euro; #oldprices.eurbulk#</span></cfoutput>
							  <cfset oldPriceGreater = "yes">
							<br />
						  </cfif>
							<!--------------------------------------------------------------------------------------->
							&euro; <cfoutput>#NumberFormat(Application.Allproducts.products["#Session.jcid#"].eurbulk, "___.__")#</cfoutput>/<cfif FindNoCase("earring", Application.Allproducts.products["#Session.jcid#"].jccatname) EQ 0>Piece<cfelse>Pair</cfif>
							<cfif #oldprices.eurbulk# GT #Application.Allproducts.products["#Session.jcid#"].eurbulk# AND (100-(#Application.Allproducts.products["#Session.jcid#"].eurbulk#/#oldprices.eurbulk#*100)) GTE 20>
								<br />
								<cfset x = 100-(#Application.Allproducts.products["#Session.jcid#"].eurbulk#/#oldprices.eurbulk#*100)>
								<cfoutput><span class="product_links">#NumberFormat(x, "___")#% Discount</span></cfoutput>
							</cfif>
						</cfif>
						<span class="oldpricetag">
						<cfelseif Session.currency EQ "usd">
					  <cfif Session.buyerCat EQ "consumer" OR Session.buyerCat EQ "AP">
						<!--- oldPrices ----------------------------------------------------------------------------->
						<cfif #oldprices.usdretail# GT #Application.Allproducts.products["#Session.jcid#"].usdretail# AND (100-(#Application.Allproducts.products["#Session.jcid#"].usdretail#/#oldprices.usdretail#*100)) GTE 20>
						  <cfoutput><span class="oldpricetag">$ #oldprices.usdretail#</span></cfoutput>
						  <cfset oldPriceGreater = "yes">
						  <br />
						</cfif>
						<!------------------------------------------------------------------------------------------->
					  </cfif>
						<cfif Session.buyerCat EQ "consumer" OR Session.buyerCat EQ "AP">
							$ <cfoutput>#NumberFormat(Application.Allproducts.products["#Session.jcid#"].usdretail, "___.__")#</cfoutput>/<cfif FindNoCase("earring", Application.Allproducts.products["#Session.jcid#"].jccatname) EQ 0>Piece<cfelse>Pair</cfif>
							<cfif #oldprices.usdretail# GT #Application.Allproducts.products["#Session.jcid#"].usdretail# AND (100-(#Application.Allproducts.products["#Session.jcid#"].usdretail#/#oldprices.usdretail#*100)) GTE 20>
								<br />
								<cfset x = 100-(#Application.Allproducts.products["#Session.jcid#"].usdretail#/#oldprices.usdretail#*100)>
								<cfoutput><span class="product_links">#NumberFormat(x, "___")#% Discount</span></cfoutput>
							</cfif>
						<cfelseif Session.buyerCat EQ "wholesaler">
							<!--- oldPrices --------------------------------------------------------------------------->
							<cfif #oldprices.jcnote09# GT #Application.Allproducts.products["#Session.jcid#"].jcnote09# AND (100-(#Application.Allproducts.products["#Session.jcid#"].jcnote09#/#oldprices.jcnote09#*100)) GTE 20>
								<cfoutput><span class="oldpricetag">$ #oldprices.jcnote09#</span></cfoutput>
								<cfset oldPriceGreater = "yes">		
							<br />
							</cfif>
							<!----------------------------------------------------------------------------------------->
							$ <cfoutput>#NumberFormat(Application.Allproducts.products["#Session.jcid#"].jcnote09, "___.__")#</cfoutput>/<cfif FindNoCase("earring", Application.Allproducts.products["#Session.jcid#"].jccatname) EQ 0>Piece<cfelse>Pair</cfif>
							<cfif #oldprices.jcnote09# GT #Application.Allproducts.products["#Session.jcid#"].jcnote09# AND (100-(#Application.Allproducts.products["#Session.jcid#"].jcnote09#/#oldprices.jcnote09#*100)) GTE 20>
								<br />
								<cfset x = 100-(#Application.Allproducts.products["#Session.jcid#"].jcnote09#/#oldprices.jcnote09#*100)>
								<cfoutput><span class="product_links">#NumberFormat(x, "___")#% Discount</span></cfoutput>
							</cfif>
						<cfelseif Session.buyerCat EQ "bulk">
							<!--- oldPrices ------------------------------------------------------------------------->
							<cfif #oldprices.usdbulk# GT #Application.Allproducts.products["#Session.jcid#"].usdbulk# AND (100-(#Application.Allproducts.products["#Session.jcid#"].usdbulk#/#oldprices.usdbulk#*100)) GTE 20>
								<span class="oldpricetag"><cfoutput>$ #oldprices.usdbulk#</cfoutput></span>
								<cfset oldPriceGreater = "yes">
							<br />
							</cfif>
							<!--------------------------------------------------------------------------------------->
							$ <cfoutput>#NumberFormat(Application.Allproducts.products["#Session.jcid#"].usdbulk, "___.__")#</cfoutput>/<cfif FindNoCase("earring", Application.Allproducts.products["#Session.jcid#"].jccatname) EQ 0>Piece<cfelse>Pair</cfif>
							<cfif #oldprices.usdbulk# GT #Application.Allproducts.products["#Session.jcid#"].usdbulk# AND (100-(#Application.Allproducts.products["#Session.jcid#"].usdbulk#/#oldprices.usdbulk#*100)) GTE 20>
								<br />
								<cfset x = 100-(#Application.Allproducts.products["#Session.jcid#"].usdbulk#/#oldprices.usdbulk#*100)>
								<cfoutput><span class="product_links">#NumberFormat(x, "___")#% Discount</span></cfoutput>
							</cfif>
						</cfif>
				  </cfif></td><cfif Session.isCustomQty EQ "yes" OR Session.isCustomColor EQ "yes"><td class="product_links" style="text-decoration:none"> + 20%</td></cfif>			  
				</tr>
				
				
				
				<cfif Session.buyerCat EQ "consumer" AND Application.Allproducts.products["#Session.jcid#"].jccatname EQ "Ring">
				  <tr>
					<td colspan="2" align="center" valign="top" class="Informal_text_dynamic"><!---<cfquery name="pageName" dbtype="query">
	select active from contents where pages_id = 'product_details_size'
</cfquery>--->Size : <!---<cfquery name="pageName" dbtype="query">
	select active from contents where pages_id = 'product_details_ringsizer'
</cfquery>---><a onclick="processing()" href="/EN/ringsizer/ringsizer.cfm">View ringsizer</a>
					<SELECT name="size">
							<CFIF #Application.Allproducts.products["#Session.jcid#"].jcsizname01# EQ "">
								<option value="5">5</option>
								<option value="6">6</option>
								<option value="7">7</option>
								<option value="8">8</option>
								<option value="9">9</option>
								<option value="10">10</option>
								<option value="11">11</option>
								<option value="12">12</option>
								<option value="13">13</option>
								<option value="14">14</option>
								<option value="15">15</option>
							<cfelse>
								<cfoutput>
									<OPTION value="#Application.Allproducts.products['#Session.jcid#'].jcsizname01#">#Application.Allproducts.products["#Session.jcid#"].jcsizname01#</OPTION>
									<CFIF #Application.Allproducts.products["#Session.jcid#"].jcsizname02# IS NOT "">
										<OPTION value="#Application.Allproducts.products['#Session.jcid#'].jcsizname02#">#Application.Allproducts.products["#Session.jcid#"].jcsizname02#</OPTION>
									</CFIF>
									<CFIF #Application.Allproducts.products["#Session.jcid#"].jcsizname03# IS NOT "">
										<OPTION value="#Application.Allproducts.products['#Session.jcid#'].jcsizname03#">#Application.Allproducts.products["#Session.jcid#"].jcsizname03#</OPTION>
									</CFIF>
									<CFIF #Application.Allproducts.products["#Session.jcid#"].jcsizname04# IS NOT "">
										<OPTION value="#Application.Allproducts.products['#Session.jcid#'].jcsizname04#">#Application.Allproducts.products["#Session.jcid#"].jcsizname04#</OPTION>
									</CFIF>
									<CFIF #Application.Allproducts.products["#Session.jcid#"].jcsizname05# IS NOT "">
										<OPTION value="#Application.Allproducts.products['#Session.jcid#'].jcsizname05#">#Application.Allproducts.products["#Session.jcid#"].jcsizname05#</OPTION>
									</CFIF>
									<CFIF #Application.Allproducts.products["#Session.jcid#"].jcsizname06# IS NOT "">
										<OPTION value="#Application.Allproducts.products['#Session.jcid#'].jcsizname06#">#Application.Allproducts.products["#Session.jcid#"].jcsizname06#</OPTION>
									</CFIF>
									<CFIF #Application.Allproducts.products["#Session.jcid#"].jcsizname07# IS NOT "">
										<OPTION value="#Application.Allproducts.products['#Session.jcid#'].jcsizname07#">#Application.Allproducts.products["#Session.jcid#"].jcsizname07#</OPTION>
									</CFIF>
									<CFIF #Application.Allproducts.products["#Session.jcid#"].jcsizname08# IS NOT "">
										<OPTION value="#Application.Allproducts.products['#Session.jcid#'].jcsizname08#">#Application.Allproducts.products["#Session.jcid#"].jcsizname08#</OPTION>
									</CFIF>
									<CFIF #Application.Allproducts.products["#Session.jcid#"].jcsizname09# IS NOT "">
										<OPTION value="#Application.Allproducts.products['#Session.jcid#'].jcsizname09#">#Application.Allproducts.products["#Session.jcid#"].jcsizname09#</OPTION>
									</CFIF>
									<CFIF #Application.Allproducts.products["#Session.jcid#"].jcsizname10# IS NOT "">
										<OPTION value="#Application.Allproducts.products['#Session.jcid#'].jcsizname10#">#Application.Allproducts.products["#Session.jcid#"].jcsizname10#</OPTION>
									</CFIF>
									<CFIF #Application.Allproducts.products["#Session.jcid#"].jcsizname11# IS NOT "">
										<OPTION value="#Application.Allproducts.products['#Session.jcid#'].jcsizname11#">#Application.Allproducts.products["#Session.jcid#"].jcsizname11#</OPTION>
									</CFIF>
									<CFIF #Application.Allproducts.products["#Session.jcid#"].jcsizname12# IS NOT "">
										<OPTION value="#Application.Allproducts.products['#Session.jcid#'].jcsizname12#">#Application.Allproducts.products["#Session.jcid#"].jcsizname12#</OPTION>
									</CFIF>
								</cfoutput>
							</CFIF>
				    </SELECT>				</td>
				  </tr>
			  <cfelse>
				  <input name="size" type="hidden" value="n/a" />
			  </cfif>

				<cfif Session.buyerCat EQ "consumer" AND Find("_", "#Session.jcid#") EQ 0>
				  <tr>
					<td colspan="2" align="center" valign="top" class="Informal_text_dynamic">Colour :
					<SELECT name="color">
							<CFIF #Application.Allproducts.products["#Session.jcid#"].jccolname01# IS "">
								<!--- if there is no colour listed, insert common colours --->
								<!---<cfquery name="pageName" dbtype="query">
									select active from contents where pages_id like 'product_details_cc_%'
								</cfquery>--->
								<!---<cfloop query="pageName">
									<option value="#Application.Allproducts.pageContents['product_details_cc_']._en#"><cfoutput>#Application.Allproducts.pageContents['']._en#</cfoutput></option>
								</cfloop>--->
								<option value="beige"></option>
								<option value="black"></option>
								<option value="blue"></option>
								<option value="brown"></option>
								<option value="burgundi"></option>
								<option value="clear"></option>
								<option value="green"></option>
								<option value="light pink"></option>
								<option value="orange"></option>
								<option value="pink"></option>
								<option value="purple"></option>
								<option value="red"></option>
								<option value="silver"></option>
								<option value="turquoise"></option>
								<option value="white"></option>
								<option value="yellow"></option>
							<CFELSE>
								<cfoutput>
									<OPTION value="#Application.Allproducts.products['#Session.jcid#'].jccolname01#">#Application.Allproducts.products["#Session.jcid#"].jccolname01#</OPTION>
									<CFIF #Application.Allproducts.products["#Session.jcid#"].jccolname02# IS NOT "">
										<OPTION value="#Application.Allproducts.products['#Session.jcid#'].jccolname02#">#Application.Allproducts.products["#Session.jcid#"].jccolname02#</OPTION>
									</CFIF>
									<CFIF #Application.Allproducts.products["#Session.jcid#"].jccolname03# IS NOT "">
										<OPTION value="#Application.Allproducts.products['#Session.jcid#'].jccolname03#">#Application.Allproducts.products["#Session.jcid#"].jccolname03#</OPTION>
									</CFIF>
									<CFIF #Application.Allproducts.products["#Session.jcid#"].jccolname04# IS NOT "">
										<OPTION value="#Application.Allproducts.products['#Session.jcid#'].jccolname04#">#Application.Allproducts.products["#Session.jcid#"].jccolname04#</OPTION>
									</CFIF>
									<CFIF #Application.Allproducts.products["#Session.jcid#"].jccolname05# IS NOT "">
										<OPTION value="#Application.Allproducts.products['#Session.jcid#'].jccolname05#">#Application.Allproducts.products["#Session.jcid#"].jccolname05#</OPTION>
									</CFIF>
									<CFIF #Application.Allproducts.products["#Session.jcid#"].jccolname06# IS NOT "">
										<OPTION value="#Application.Allproducts.products['#Session.jcid#'].jccolname06#">#Application.Allproducts.products["#Session.jcid#"].jccolname06#</OPTION>
									</CFIF>
									<CFIF #Application.Allproducts.products["#Session.jcid#"].jccolname07# IS NOT "">
										<OPTION value="#Application.Allproducts.products['#Session.jcid#'].jccolname07#">#Application.Allproducts.products["#Session.jcid#"].jccolname07#</OPTION>
									</CFIF>
									<CFIF #Application.Allproducts.products["#Session.jcid#"].jccolname08# IS NOT "">
										<OPTION value="#Application.Allproducts.products['#Session.jcid#'].jccolname08#">#Application.Allproducts.products["#Session.jcid#"].jccolname08#</OPTION>
									</CFIF>
									<CFIF #Application.Allproducts.products["#Session.jcid#"].jccolname09# IS NOT "">
										<OPTION value="#Application.Allproducts.products['#Session.jcid#'].jccolname09#">#Application.Allproducts.products["#Session.jcid#"].jccolname09#</OPTION>
									</CFIF>
									<CFIF #Application.Allproducts.products["#Session.jcid#"].jccolname10# IS NOT "">
										<OPTION value="#Application.Allproducts.products['#Session.jcid#'].jccolname10#">#Application.Allproducts.products["#Session.jcid#"].jccolname10#</OPTION>
									</CFIF>
									<CFIF #Application.Allproducts.products["#Session.jcid#"].jccolname11# IS NOT "">
										<OPTION value="#Application.Allproducts.products['#Session.jcid#'].jccolname11#">#Application.Allproducts.products["#Session.jcid#"].jccolname11#</OPTION>
									</CFIF>
									<CFIF #Application.Allproducts.products["#Session.jcid#"].jccolname12# IS NOT "">
										<OPTION value="#Application.Allproducts.products['#Session.jcid#'].jccolname12#">#Application.Allproducts.products["#Session.jcid#"].jccolname12#</OPTION>
									</CFIF>
								</cfoutput>
							</CFIF>
				    </SELECT>				</td>
				  </tr>
			  <cfelse>
				  	<tr>
				  	  <td colspan="2" align="center" valign="top" class="Informal_text_dynamic">
					  	<input name="color" type="hidden" value="n/a" />
						<!---<cfoutput>#pageName.active#</cfoutput> : n/a--->&nbsp;
					  </td>
					</tr>
			  </cfif>
			<!---</cfif>--->
				
			
				<!---<cfquery name="pageName" dbtype="query">
					select active from contents where pages_id = 'product_details_qty'
				</cfquery>--->
			<cfif Session.isCustomQty EQ "yes" OR Session.isCustomColor EQ "yes">
				<tr>
					  <td colspan="2" align="center" valign="top" class="Informal_text_dynamic">Quantity :<BR />
						<!--- get pack sizes and insert as headers for prices --->
						<cfoutput><cfset packsize = NumberFormat(#Application.Allproducts.products["#Session.jcid#"].jcsku#, "___")>
					  <cfif Session.buyerCat EQ "bulk">
							<cfset p = packsize * 24>
						<cfelse>
							<cfset p = packsize * 12>
						</cfif></cfoutput>
						<select name="quantity">
							<option value="1">1 <cfif FindNoCase("earring", Application.Allproducts.products["#Session.jcid#"].jccatname) EQ 0>Piece<cfelse>Pair</cfif></option>
							<cfoutput>
								<cfloop index = "i" from = "2" to = "#p-1#">
									<option value="#i#">#i# <cfif FindNoCase("earring", Application.Allproducts.products["#Session.jcid#"].jccatname) EQ 0>Piece<cfelse>Pair</cfif>s</option>
								</cfloop>
							</cfoutput>
						</select>					</td>
				</tr>
			<cfelse>
				<tr>
					  <td colspan="2" align="center" valign="top" class="Informal_text_dynamic">Quantity :<BR />
					  <cfif Session.buyerCat EQ "consumer">
							<select name="quantity">
								<option value="1" selected="selected">1</option>
								<option value="2">2</option>
								<option value="3">3</option>
								<option value="4">4</option>
								<option value="5">5</option>
								<option value="6">6</option>
								<option value="7">7</option>
								<option value="8">8</option>
								<option value="9">9</option>
								<option value="10">10</option>
							</select>
						<cfelseif Session.buyerCat EQ "wholesaler" OR Session.buyerCat EQ "AP">
							<!--- get pack sizes and insert as headers for prices --->
							<cfoutput><cfset packsize = NumberFormat(#Application.Allproducts.products["#Session.jcid#"].jcsku#, "___")></cfoutput>
							
							<select name="quantity">
								<!---<cfquery name="pageName" dbtype="query">
	select active from contents where pages_id = 'product_details_sample'
</cfquery>---><option value="1">1 <cfif FindNoCase("earring", Application.Allproducts.products["#Session.jcid#"].jccatname) EQ 0>Piece<cfelse>Pair</cfif> (sample only)</option>
								<cfoutput>
									<!---<cfquery name="pageName" dbtype="query">
	select active from contents where pages_id = 'product_details_pack'
</cfquery>---><option value="#packsize#" selected="selected">1 pack (#packsize#)</option>
								<cfif Application.Allproducts.products["#Session.jcid#"].jcflag7 EQ 'Yes'>
									<cfloop index = "i" from = 2 to = 12>
										<!---<cfquery name="pageName" dbtype="query">
	select active from contents where pages_id = 'product_details_packs'
</cfquery>---><option value="#packsize*i#">#i# packs (#packsize*i#)</option>
									</cfloop>
								<cfelse>
									<cfoutput><cfloop index = "i" from = 2 to = #min(int(Application.Allproducts.products["#Session.jcid#"].jcstock/packsize),12)#></cfoutput>
										<!---<cfquery name="pageName" dbtype="query">
	select active from contents where pages_id = 'product_details_packs'
</cfquery>---><option value="#packsize*i#">#i# packs (#packsize*i#)</option>
									</cfloop>
								</cfif>
								</cfoutput>
							</select>
						<cfelseif Session.buyerCat EQ "bulk">
							<!--- get pack sizes and insert as headers for prices --->
							<cfoutput><cfset packsize = NumberFormat(#Application.Allproducts.products["#Session.jcid#"].jcsku#, "___")></cfoutput>
							
							<select name="quantity">
								<!---<cfquery name="pageName" dbtype="query">
	select active from contents where pages_id = 'product_details_sample'
</cfquery>---><option value="1">1 <cfif FindNoCase("earring", Application.Allproducts.products["#Session.jcid#"].jccatname) EQ 0>Piece<cfelse>Pair</cfif> (sample only)</option>
								<cfoutput>
									<!---<cfquery name="pageName" dbtype="query">
	select active from contents where pages_id = 'product_details_pack'
</cfquery>---><option value="#packsize#" selected="selected">1 pack (#packsize#)</option>
								<cfif Application.Allproducts.products["#Session.jcid#"].jcflag7 EQ 'Yes'>
									<cfloop index = "i" from = 2 to = 24>
										<!---<cfquery name="pageName" dbtype="query">
	select active from contents where pages_id = 'product_details_packs'
</cfquery>---><option value="#packsize*i#">#i# packs (#packsize*i#)</option>
									</cfloop>
								<cfelse>
									<cfoutput><cfloop index = "i" from = 2 to = #min(int(Application.Allproducts.products["#Session.jcid#"].jcstock/packsize),24)#></cfoutput>
										<!---<cfquery name="pageName" dbtype="query">
	select active from contents where pages_id = 'product_details_packs'
</cfquery>---><option value="#packsize*i#">#i# packs (#packsize*i#)</option>
									</cfloop>
								</cfif>
								</cfoutput>
							</select>
					  </cfif>			  </td>
				</tr>
			</cfif>
			
			
			<cfif session.buyerCat NEQ "consumer" AND session.buyerCat NEQ "bulk" AND session.password NEQ "temp">
				<tr>
				  <!---<cfquery name="pageName" dbtype="query">
	select active from contents where pages_id = 'product_details_customBis'
</cfquery>---><td colspan="2" align="center"><a onclick="processing()" href="/EN/model/product_custom_pack.cfm?jcid=#URLEncodedFormat(session.jcid)#"><span class="Informal_text_dynamic">Select custom colours or quantity here</span></a></td>
				</tr>
			</cfif>
			
			
			
				<tr>
				  <td colspan="2" align="center" valign="top">
					<cfoutput>
					<input name="jcid" type="hidden" value="#Session.jcid#" /></cfoutput>
                    <!---<cfquery name="pageName" dbtype="query">
	select active from contents where pages_id = 'product_details_addBasket'
</cfquery>---><input name="Submit_#Session.jcid#" type="submit" onclick="processing()" class="Informal_text_dynamic" id="Add_to_order_ID" value="Add to my basket" /><BR />
                    <!---&nbsp;&nbsp;&nbsp;&nbsp;<iframe src="http://www.facebook.com/plugins/like.php?href=#urlEncodedFormat(t)#&amp;layout=button_count&amp;show_faces=true&amp;width=150&amp;action=like&amp;colorscheme=light&amp;height=30" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:150px; height:30px;" allowtransparency="true"></iframe>--->
                    <BR />
                  <CFOUTPUT><!---<cfquery name="pageName" dbtype="query">
	select active from contents where pages_id = 'product_details_moreDetails'
</cfquery>---><a onclick="processing()" href="/EN/details/details.cfm?jcid=#urlEncodedFormat(Session.jcid)#" class="Informal_text_dynamic">More Details...</a></CFOUTPUT>
                </td>
	    </tr>
				<tr>
				  <td colspan="2" align="center" valign="top"><cfif #Application.Allproducts.products["#Session.jcid#"].jcspoff# EQ "yes"><CFOUTPUT>
				    <div align="center"><img src="/graphics/pricereducedticker.jpg"/></div>
				  </CFOUTPUT>
				  </cfif>
				    <div align="center">
				      <cfif #Application.Allproducts.products["#Session.jcid#"].jcbestsell# LT "200">
				        <CFOUTPUT><img src="/graphics/bestsellersticker.jpg"/></CFOUTPUT>
			          </cfif>
						<cfif #Application.Allproducts.products["#Session.jcid#"].jcid# GTE "<cfoutput>#Application.newItems#</cfoutput>">
					  <img src="/graphics/newsticker.jpg"/>
					</cfif>
			        </div>
				    <cfif oldPriceGreater EQ "yes">
				      <div align="center"><CFOUTPUT><img src="/graphics/salesticker.jpg" alt="ON SALE<CFOUTPUT>#Application.Allproducts.products["#Session.jcid#"].jccatname# #Application.Allproducts.products["#Session.jcid#"].jcuniqdesc# in #Application.Allproducts.products["#Session.jcid#"].jccatname# #Application.Allproducts.products["#Session.jcid#"].jcmat1#</CFOUTPUT>"title="ON SALE<CFOUTPUT>#Application.Allproducts.products["#Session.jcid#"].jccatname# #Application.Allproducts.products["#Session.jcid#"].jcuniqdesc# in #Application.Allproducts.products["#Session.jcid#"].jccatname# #Application.Allproducts.products["#Session.jcid#"].jcmat1#</CFOUTPUT>"/></CFOUTPUT></div>
				    </cfif>
                    <cfif #Application.Allproducts.products["#Session.jcid#"].jcflag7# EQ "no">
                    <CFOUTPUT><img src="/graphics/limitedstocks.jpg" alt="<CFOUTPUT>#Application.Allproducts.products["#Session.jcid#"].jccatname# #Application.Allproducts.products["#Session.jcid#"].jcuniqdesc# in #Application.Allproducts.products["#Session.jcid#"].jccatname# #Application.Allproducts.products["#Session.jcid#"].jcmat1#</CFOUTPUT>"title="ON SALE<CFOUTPUT>#Application.Allproducts.products["#Session.jcid#"].jccatname# #Application.Allproducts.products["#Session.jcid#"].jcuniqdesc# in #Application.Allproducts.products["#Session.jcid#"].jccatname# #Application.Allproducts.products["#Session.jcid#"].jcmat1#</CFOUTPUT>"/></CFOUTPUT></div>
				    </cfif></td>
	    </tr></table>
	</cfoutput></form>

Open in new window


and lastly the footer.cfm :
<style>			
a img {border:none}
}
</style>		

<table width="900" align="center">
  <tr>
    <td colspan="5" align="left" valign="middle">&nbsp;</td>
    <td colspan="1" align="left" valign="middle">&nbsp;</td>
    <td colspan="5" align="right" valign="middle">&nbsp;</td>
  </tr>
  <tr>
    <cfoutput><td colspan="5" align="left" valign="middle"><a onclick="processing()" href="/EN/home/home.cfm" class="product_links">Home</a>&nbsp;&nbsp;&nbsp;<a onclick="processing()" href="/EN/terms/terms.cfm" class="product_links">Terms of trade</a>&nbsp;&nbsp;&nbsp;<a onclick="processing()" href="/EN/contacts/contacts.cfm" class="product_links">Contact us</a>
	<cfif Session.loggedIn EQ "yes" AND session.buyerCat NEQ "consumer">
	  &nbsp;&nbsp;&nbsp;<a onclick="processing()" href="/EN/aboutus/aboutus.cfm" class="product_links">About us</a>
	  </cfif>
	<cfif Session.loggedIn EQ "yes" AND session.buyerCat NEQ "consumer">
	  &nbsp;&nbsp;&nbsp;<a onclick="processing()" href="/EN/showdates/showdates.cfm" class="product_links">Show dates</a>
	  </cfif>
	<cfif Session.loggedIn EQ "no" AND session.buyerCat EQ "consumer">
	  &nbsp;&nbsp;&nbsp;<a onclick="processing()" href="/EN/search/searchretailer.cfm" class="product_links">Find a Joe Cool retailer</a>
	</cfif></td>
	  <td colspan="1" align="left" valign="middle"><!---<a onclick="processing()" href="/EN/specials/products_resultssale.cfm?catname=all&page=1&rngname=all&items=#urlEncodedFormat(Session.ItemDisplayed)#&sortby=#urlEncodedFormat(Session.sortBy)#" class="product_links"><img alt="Sales" src="/graphics/salesticker.jpg" /></a>--->&nbsp;</td>
    <td colspan="5" align="right" valign="middle"><a onclick="processing()" href="/EN/products/products.cfm" class="product_links">Products</a>&nbsp;&nbsp;&nbsp;<a onclick="processing()" href="/EN/most_wanted/products_results.cfm?catname=all&page=1&rngname=all&items=#urlEncodedFormat(Session.ItemDisplayed)#&sortby=bestseller" class="product_links">Best Sellers</a>&nbsp;&nbsp;&nbsp;<a onclick="processing()" href="/EN/specials/products_results.cfm?catname=all&page=1&rngname=all&items=#urlEncodedFormat(Session.ItemDisplayed)#&sortby=#urlEncodedFormat(Session.sortBy)#" class="product_links">Special Offers</a>&nbsp;&nbsp;&nbsp;<a onclick="processing()" href="/EN/new_items/products_results.cfm?catname=all&page=1&rngname=all&items=#urlEncodedFormat(Session.ItemDisplayed)#&sortby=#urlEncodedFormat(Session.sortBy)#" class="product_links">New Items</a></td></cfoutput>
  </tr>
</table>
<table width="900" align="center">
  <cfif #Arguments.targetPage# NEQ "/EN/products/products.cfm" 
			  AND #Arguments.targetPage# NEQ "/EN/most_wanted/most_wanted.cfm" 
			  AND #Arguments.targetPage# NEQ "/EN/new_items./new_items..cfm" 
			  AND #Arguments.targetPage# NEQ "/EN/specials/special_offers.cfm.cfm">
	<cfif session.language EQ "en">
		<cfset jccat = "jccatname">
	<cfelseif session.language EQ "es">
		<cfset jccat = "espcateg">
	<cfelseif session.language EQ "fr">
		<cfset jccat = "frecateg">
	<cfelseif session.language EQ "ge">
		<cfset jccat = "gercateg">
	<cfelseif session.language EQ "it">
		<cfset jccat = "itlcateg">
	<cfelse>
		<cfset jccat = "jccatname">
	</cfif>
	  <tr>
	    <td height="4" colspan="2" align="left" class="Informal_text_non_dynamic"><HR /></td>
    </tr>
	  <tr>
	    <td colspan="2" align="left" class="Informal_text_non_dynamic"><cfquery name="cat" datasource="joecool_web">
			  select distinct #jccat# as jcview, count(#jccat#) as sum, jccatname, jcid from jcstktabl 
			  <cfif session.buyerCat EQ "consumer">where jcid not like '%COM' 
			  <!---AND jcid not in (select jcidRef from jcstktabl_cropped where jcidRef LIKE jcstktabl.jcid)--->
			  <cfelse>where jcid not like '%!_%'escape '!'
			  </cfif>
			  group by #jccat# order by #jccat# asc
			</cfquery>
		<cfoutput>
		  <cfloop query="cat">
	    <a onclick="processing()" href="/EN/products/products_results.cfm?catname=#urlEncodedFormat(jccatname)#&rngname=all&items=#urlEncodedFormat(Session.ItemDisplayed)#&page=1&sortby=#urlEncodedFormat(Session.sortBy)#"><cfif jcview NEQ "">#jcview#<cfelse>Other</cfif> (#sum#)	  </a> - </cfloop></cfoutput></td>
	</tr>
	  <tr>
	    <td colspan="2" align="left" class="Informal_text_non_dynamic"><HR /></td>
    </tr>
	  <tr>
	    <td width="447" rowspan="3" align="left" valign="top" class="Informal_text_non_dynamic"><p class="thumb_title_style">We deliver with : </p>
<p><img src="../../graphics/logodpd.jpg" width="147" height="50" alt="Joe cool ships with DPD" /><img src="../../graphics/logoups.jpg" width="147" height="50" alt="Joe cool ships with UPS" /><img src="../../graphics/logofedex.jpg" width="147" height="50" alt="Joe cool ships with Fedex" /><img src="../../graphics/logochrono.jpg" width="147" height="50" alt="Joe Cool ships with Chronospost" /><img src="../../graphics/logoroyalmail.jpg" width="147" height="50" alt="Joe Cool ships with Royal mail (UK)" /></p></td>
	    <td height="56" align="right" class="Informal_text_non_dynamic"><span class="thumb_title_style">Join us<BR /><img src="../../graphics/social_icons.jpg" alt="Find Joe Cool on social networks" width="120" height="23" border="0" usemap="#Map_social" /></span><BR /></td>
    </tr>
	  <tr>
	    <td width="441" height="56" align="right" class="Informal_text_non_dynamic"><span class="thumb_title_style">Check your order and delivery status</span><BR /> 
	      Tel : 0044(0)1334 659 836 (Direct Line)<br /></td>
    </tr>
	  <tr>
	    <td rowspan="2" align="right" class="Informal_text_non_dynamic"><div id="thawteseal" style="text-align:right;" title="Cliquez pour vérifier - Ce site a choisi les Certificats SSL de Thawte afin de sécuriser l'e-commerce et les communications confidentielles.">
<div><script type="text/javascript" src="https://seal.thawte.com/getthawteseal?host_name=www.joe-cool.co.uk&amp;size=S&amp;lang=en"></script></div>
<div><a href="http://www.thawte.com/ssl-certificates/" target="_blank" style="color:#000000; text-decoration:none; font:bold 10px arial,sans-serif; margin:0px; padding:0px;">ABOUT SSL CERTIFICATES</a></div>
</div></td>
    </tr>
	  <tr>
	    <td align="left" valign="top" class="thumb_title_style">Talk to our agents :
       
					<a onClick="processing()" href="https://www.joe-cool.co.uk/EN/contacts/contacts.cfm"><img src="/graphics/flagEn.png" /></a>
					<a onClick="processing()" href="https://www.joe-cool.co.uk/EN/contacts/contacts.cfm"><img src="/graphics/flagFr.png" /></a>
					<a onClick="processing()" href="https://www.joe-cool.co.uk/EN/contacts/contacts.cfm"><img src="/graphics/flagSp.png" /></a>
					<a onClick="processing()" href="https://www.joe-cool.co.uk/EN/contacts/contacts.cfm"><img src="/graphics/flagIt.png" /></a>
					<a onClick="processing()" href="https://www.joe-cool.co.uk/EN/contacts/contacts.cfm"><img src="/graphics/flagGe.png" /></a>
				
                </td>
    </tr>
  </cfif>
	
		    <tr><td colspan="2" align="center"><span class="Informal_text_non_dynamic">&copy; Joe Cool Uk Ltd jewellery online store.</span>
		</td></tr>
		</table>
		</td>
	</tr>
</table>
<map name="Map_social" id="Map_social">
  <area shape="rect" coords="-5,-16,23,26" href="https://www.facebook.com/pages/Joe-Cool-UK-Ltd/172620232752706" target="_new" />
  <area shape="rect" coords="27,-5,45,22" href="https://twitter.com/Joecoolukltd" target="_new" />
  <area shape="rect" coords="48,-1,195,44" href="http://pinterest.com/joecoolukltd/" target="_new" />
</map>

Open in new window


Additionally, here are the called static methods from application.cfc, to construct the title, the navigation tool and the sort&filter tool :
<!--- addTitle --->
	<cffunction  name="addTitle" access="public" returntype="string" output="yes" description="construct the thumbs page's title">
		<cfargument name="cat" required="yes" type="string" />
		<cfargument name="rng" required="yes" type="string" />
		<cfargument name="mode" required="yes" type="numeric" hint="0=all ; 1=best sellers ; 2=special offers ; 3=new items ; 4=search ; 5=sales" />
		
		<!---<cfquery name="contents" datasource="joecool_web">
			select pages_id, _#session.language# as active from pages_contents 
			where pages_id like 'appTitle%' 
		</cfquery>--->
		
		<cfif Arguments.mode EQ 4>
			<!---<cfquery name="searchResult" dbtype="query">
				select active from contents where pages_id = 'appTitle_searchResult'
			</cfquery>--->
			<cfset title = "Search result for #Arguments.rng#">
		<cfelse>
			<cfset title = "">
			<cfif Arguments.mode EQ 0>
				<!---<cfquery name="products" dbtype="query">
					select active from contents where pages_id = 'appTitle_products'
				</cfquery>--->
				<cfset title &= "Our products">
			<cfelseif Arguments.mode EQ 1>
				<!---<cfquery name="bestSellers" dbtype="query">
					select active from contents where pages_id = 'appTitle_bestSellers'
				</cfquery>--->
				<cfset title &= "Best sellers">
			<cfelseif Arguments.mode EQ 2>
				<!---<cfquery name="specialOffers" dbtype="query">
					select active from contents where pages_id = 'appTitle_specialOffers'
				</cfquery>--->
				<cfset title &= "Special offers">
			<cfelseif Arguments.mode EQ 3>
				<!---<cfquery name="newItems" dbtype="query">
					select active from contents where pages_id = 'appTitle_newItems'
				</cfquery>--->
				<cfset title &= "New items">
			<cfelseif Arguments.mode EQ 5>
				<!---<cfquery name="sales" dbtype="query">
					select active from contents where pages_id = 'appTitle_sales'
				</cfquery>--->
				<cfset title &= "Sales">
			</cfif>
			
			<cfif Arguments.cat EQ "">
				<!---<cfquery name="other" dbtype="query">
					select active from contents where pages_id = 'appTitle_other'
				</cfquery>--->
				<cfset Arguments.cat = "Other">
			</cfif>
			<cfif Arguments.rng EQ "">
				<!---<cfquery name="other" dbtype="query">
					select active from contents where pages_id = 'appTitle_other'
				</cfquery>--->
				<cfset Arguments.rng = "Other">
			</cfif>
			
			<!---<cfquery name="allProducts" dbtype="query">
				select active from contents where pages_id = 'appTitle_allProducts'
			</cfquery>--->
			<cfif Find("All", Arguments.cat) EQ 0>
				<cfset title &= " (#Arguments.rng#">
				<cfif Arguments.cat EQ "All"><cfset title &= " products)">
				<cfelse><cfset title &= " #Arguments.cat#)"></cfif>
			<cfelse>
				<cfif Arguments.cat EQ "All"><cfset title &= " (products)">
				<cfelse><cfset title &= " (#Arguments.cat#)"></cfif>
			</cfif>
		</cfif>
		
		<cfreturn title />
    </cffunction>

	<!--- addNavLinks --->
	<cffunction  name="addNavLinks" access="public" returntype="void" output="true" hint="construct the navigation's history (previous pages viewed)">
		<cfargument name="page" required="yes" type="string" />
		<cfargument name="url" required="yes" type="string" />
		<cfargument name="thumbsPage" required="no" default="0" />
		
		<!--- initialise variables --->
		<cfif NOT IsDefined("Session.previousPages")>
			<cfset Session.previousPages = ArrayNew(2)><!--- holds previous viewed pages informations : page name abbreviated [x][1],  page name full [x][2], and its url [x][3] --->
		</cfif>
		<cfset var pageNameNormalised = ""><!--- holds the page name abbreviated --->
		<cfset totalPages = ArrayLen(Session.previousPages)><!--- total entries for Session.previousPages --->
		<cfset isStored = false><!--- holds the result of the test "test if page was already viewed" --->

		<!--- initialise variables - previous products --->
		<cfif NOT IsDefined("Session.previousProducts")>
			<cfset Session.previousProducts = ArrayNew(1)>
		</cfif>
		
		<!--- if page name is too long : abbreviate it --->
		<cfif Len(Arguments.page) GT 40>
			<cfset pageNameNormalised = Left(Arguments.page, 40) & "...">
		<cfelse>
			<cfset pageNameNormalised = Arguments.page>
		</cfif>
		
		<!--- if it's a page containing subpages (thumbs pages) : add the subpages number to the full and abbreviated page names --->
		<cfif Arguments.thumbsPage GT 0>
			<cfset pageNameNormalised &= " (page #Arguments.thumbsPage#)">
			<cfset Arguments.page &= " (page #Arguments.thumbsPage#)">
		</cfif>

		<!--- store page - previous products --->
		<cfif find("details/details.cfm", Arguments.url)>
			<cfset isFound = false>
			<cfset isFoundIndex = 0>
			<cfset pos = len(CGI.QUERY_STRING) - find("jcid=", CGI.QUERY_STRING) - 4>
			<cfset id = right(CGI.QUERY_STRING, pos)>
			<cfset id = replace(id, "%5F", "_")>
			<cfloop array="#Session.previousProducts#" index="pp">
				<cfset isFoundIndex ++> <cfif pp EQ "#id#"> <cfset isFound = true> <cfbreak> </cfif>
			</cfloop>
			<cfif isFound EQ false>
				<cfif arraylen(session.previousProducts) LT 6>
					<cfset session.previousProducts["#arraylen(session.previousProducts)+1#"] = "#id#">
				<cfelse>
					<cfloop index="i" from="1" to="#arraylen(session.previousProducts)-1#"> <cfset arraySwap(session.previousProducts, i, i+1)> </cfloop>
					<cfset session.previousProducts["#arraylen(session.previousProducts)#"] = "#id#">
				</cfif>
			<cfelseif arraylen(session.previousProducts) GT 1>
				<cfloop index="i" from="#isFoundIndex#" to="#arraylen(session.previousProducts)-1#"> <cfset arraySwap(session.previousProducts, i, i+1)> </cfloop>
			</cfif>
		</cfif>
		
		<!--- test if page was already viewed --->
		<cfif totalPages GT 0 AND Session.previousPages[totalPages][3] EQ Arguments.url>
			<!--- found --->
			<cfset isStored = true>
		</cfif>
		
		<!--- if current page ISN'T in history --->
		<cfif isStored EQ false>
			<!--- if the maximum stored pages IS reached -> swap all array to put the older entry at the newer position and then overwrite it with current page --->
			<cfif totalPages EQ 13>
				<cfloop from="2" to="#totalPages#" step="1" index="j">
					<cfset ArraySwap(Session.previousPages, j-1, j)>
				</cfloop>
				<cfset Session.previousPages[totalPages][1] = pageNameNormalised>
				<cfset Session.previousPages[totalPages][2] = Arguments.page>
				<cfset Session.previousPages[totalPages][3] = Arguments.url>
			<!--- if the maximum stored pages ISN'T reached -> append current page's data --->
			<cfelse>
				<cfset Session.previousPages[totalPages+1][1] = pageNameNormalised>
				<cfset Session.previousPages[totalPages+1][2] = Arguments.page>
				<cfset Session.previousPages[totalPages+1][3] = Arguments.url>
			</cfif>
		</cfif>
		
		<!---<cfquery name="contents" datasource="joecool_web">
			select pages_id, _#session.language# as active from pages_contents 
			where pages_id like 'appNavLinks%' 
		</cfquery>
		
		<cfquery name="previousPage" dbtype="query">
			select active from contents where pages_id = 'appNavLinks_previousPage'
		</cfquery>--->
		
		<!--- display data (previous pages menu) --->
		<cfoutput>
			<cfsavecontent variable="previousLink">
				<img alt="Previous pages" src="/graphics/previousPagebutton.png" align="ABSMIDDLE" />Previous pages
			</cfsavecontent>
			<cfif totalPages GT 1>
				<ul class="navPreviousPages">
					<li class"topfirst">
						<a onclick="processing()" href="#Session.previousPages[totalPages-1][3]#" title="#Session.previousPages[totalPages-1][2]#">#previousLink#</a>
						<ul>	
							<!--- loops through history and display it --->
							<cfloop from="#totalPages-1#" to="1" step="-1" index="k">
									<li>
											<cfif Session.previousPages[k][1] NEQ Session.previousPages[k][2]><cfset _title = Session.previousPages[k][2]><cfelse><cfset _title = ""></cfif>
											<a onclick="processing()" href="#Session.previousPages[k][3]#" title="#_title#">#Session.previousPages[k][1]#</a>
									</li>
							</cfloop>
						</ul>
					</li>
				</ul>
			</cfif>
		</cfoutput>
		
<!---<cfif Session.isAdmin EQ "yes">--->
		<cfoutput> <div style="float:right;"><span class="navPreviousPages">Last viewed :&nbsp;&nbsp;</span>
			<cfloop array="#Session.previousProducts#" index="pp">
				<cfif Find("_", "#pp#") EQ 0>
					<cfset local.imgPathRel = "/images/thumbs/#pp#.jpg">
					<cfset local.imgPathFull = expandPath(local.imgPathRel)>
				<cfelse>
					<cfset local.imgPathRel = "/images/details_thumbs/#pp#.jpg">
					<cfset local.imgPathFull = expandPath(local.imgPathRel)>
				</cfif>
				<cftry>
					<cfimage action="info" source="#local.imgPathFull#" structname="local.img">
				<cfcatch type="Any">
					<cfset local.imgPathRel = "/images/default.jpg">
					<cfset local.imgPathFull = expandPath(local.imgPathRel)>
					<cfset local.img.height  = 70>
					<cfset local.img.width = 70>
				</cfcatch>
				</cftry>

				<cfif local.img.height GT local.img.width>
					<cfset local.height = 70>
					<cfset local.width = local.img.width / (local.img.height / 70)>
				<cfelse>
					<cfset local.height = local.img.height / (local.img.width / 70)>
					<cfset local.width = 70>
				</cfif>
<cfset pp = replace(pp, "%5F", "_")>
				<cfset local.jccatname  = Application.Allproducts.products['#pp#'].jccatname>
				<cfset local.jcuniqdesc  = Application.Allproducts.products['#pp#'].jcuniqdesc>
				<img src="#local.imgPathRel#" height="#local.height#" width="#local.width#" alt="&copy; Joe Cool UK Ltd fashion jewelery wholesalers #local.jccatname# #local.jcuniqdesc#" 	border="0" 
					align="top" onclick="processing();document.location.href='/EN/details/details.cfm?jcid=#urlEncodedFormat(pp)#'" onmouseover="this.style.cursor='pointer';" />
			</cfloop>
		</div> </cfoutput>
<!---</cfif>--->
    </cffunction>

	<!--- addThumbsSortAndFilter --->
	<cffunction  name="addThumbsSortAndFilter" access="public" returntype="void" output="true" description="construct the sort and filter boxes for thumbs pages">
		<cfargument name="cat" required="yes" type="string" />
		<cfargument name="rng" required="yes" type="string" />
		<cfargument name="itemsPerPages" required="yes" type="string" />
		<cfargument name="itemsTotal" required="yes" type="string" />
		<cfargument name="page" required="yes" type="string" />
		<cfargument name="sortby" required="yes" type="string" />
		<cfargument name="mode" required="yes" type="numeric" hint="0=all ; 1=best sellers ; 2=special offers ; 3=new items ; 4=search ; 5=sales" />
		
		<!---<cfquery name="contents" datasource="joecool_web">
			select pages_id, _#session.language# as active from pages_contents 
			where pages_id like 'appFilter%' 
		</cfquery>
		
		<cfquery name="pageNumber" dbtype="query">
			select active from contents where pages_id = 'appFilter_page'
		</cfquery>
		<cfquery name="categories" dbtype="query">
			select active from contents where pages_id = 'appFilter_categories'
		</cfquery>
		<cfquery name="material" dbtype="query">
			select active from contents where pages_id = 'appFilter_material'
		</cfquery>
		<cfquery name="sortedBy" dbtype="query">
			select active from contents where pages_id = 'appFilter_sortedBy'
		</cfquery>
		<cfquery name="itemsPPage" dbtype="query">
			select active from contents where pages_id = 'appFilter_itemsPerPage'
		</cfquery>--->
		
		<table width="100%">
			<tr>
				<td class="Informal_text_dynamic" width="180" align="left">Page:</td>
				<!---<td class="Informal_text_dynamic" width="180" align="center">Categories:</td>
				<td class="Informal_text_dynamic" width="180" align="center">Material:</td>--->
				<td class="Informal_text_dynamic" width="180" align="center">Sorted by:</td>
				<td class="Informal_text_dynamic" width="180" align="right">Items per page:</td>
			</tr>
			<tr>
				<cfif Arguments.mode NEQ 5>
					<cfset pageTargeted = "products_results">
				<cfelse>
					<cfset pageTargeted = "products_resultssale">
				</cfif>
				
				<!--- pages navigator --->
				<cfset Session.ItemDisplayed = Arguments.itemsPerPages>
				<cfset numberPages = Fix(Arguments.itemsTotal/Session.ItemDisplayed)+1>
				<cfset _activePage = Arguments.page>
				<cfset displayOutput = "">
				<cfif _activePage EQ 1>
					<cfset displayOutput &= "|&laquo;&nbsp;&laquo;&nbsp;">
				<cfelse>
					<cfset displayOutput &= '<a onclick="processing()" href="#pageTargeted#.cfm?catname=#urlEncodedFormat(Arguments.cat)#&rngname=#urlEncodedFormat(Arguments.rng)#&items=#urlEncodedFormat(Session.ItemDisplayed)#&page=1&sortby=#urlEncodedFormat(Arguments.sortby)#" class="links_prev_next">|&laquo;</a>&nbsp;'>
					<cfset displayOutput &= '<a onclick="processing()" href="#pageTargeted#.cfm?catname=#urlEncodedFormat(Arguments.cat)#&rngname=#urlEncodedFormat(Arguments.rng)#&items=#urlEncodedFormat(Session.ItemDisplayed)#&page=#urlEncodedFormat(_activePage-1)#&sortby=#urlEncodedFormat(Arguments.sortby)#" class="links_prev_next">&laquo;</a>&nbsp;'>
				</cfif>
				<cfif numberPages LTE 9><cfset i = 1><cfset j = #numberPages#>
				<cfelse>
					<cfif _activePage LTE 5><cfset i = 1><cfset j = 9>
					<cfelseif _activePage GT #numberPages# - 4><cfset i = #numberPages#- 9><cfset j = #numberPages#>
					<cfelse><cfset i = #_activePage# - 4><cfset j = #_activePage# + 4>
					</cfif>
				</cfif>
				<cfif i GT 1 AND numberPages GT 9><cfset displayOutput &= '...&nbsp;'></cfif>
				<cfloop index="counter" from="#i#" to="#j#" step="1">
					<cfif counter EQ _activePage><cfset displayOutput &= '<b class="thumb_title_style"><u>#counter#</u></b>'>
					<cfelse><cfset displayOutput &= '<a onclick="processing()" href="#pageTargeted#.cfm?catname=#urlEncodedFormat(Arguments.cat)#&rngname=#urlEncodedFormat(Arguments.rng)#&items=#urlEncodedFormat(Session.ItemDisplayed)#&page=#urlEncodedFormat(counter)#&sortby=#urlEncodedFormat(Arguments.sortby)#" class="links_prev_next">#counter#</a>'>
					</cfif>
					<cfset displayOutput &= '&nbsp;'>
				</cfloop>
				<cfif j LT #numberPages# AND numberPages GT 9><cfset displayOutput &= '...&nbsp;'></cfif>
				<cfif _activePage EQ numberPages>
					<cfset displayOutput &= '	&raquo; &nbsp; &raquo;| &nbsp;'>
				<cfelse>
					<cfset displayOutput &= '<a onclick="processing()" href="#pageTargeted#.cfm?catname=#urlEncodedFormat(Arguments.cat)#&rngname=#urlEncodedFormat(Arguments.rng)#&items=#urlEncodedFormat(Session.ItemDisplayed)#&page=#urlEncodedFormat(_activePage+1)#&sortby=#urlEncodedFormat(Arguments.sortby)#" class="links_prev_next">&raquo;</a>&nbsp;'>
					<cfset displayOutput &= '<a onclick="processing()" href="#pageTargeted#.cfm?catname=#urlEncodedFormat(Arguments.cat)#&rngname=#urlEncodedFormat(Arguments.rng)#&items=#urlEncodedFormat(Session.ItemDisplayed)#&page=#urlEncodedFormat(numberPages)#&sortby=#urlEncodedFormat(Arguments.sortby)#" class="links_prev_next">&raquo;|</a>&nbsp;'>
				</cfif>
				<cfset displayOutput &= '&nbsp;'>
				<td class="links_prev_next" align="left"><cfoutput>#displayOutput#</cfoutput></td>
				
				<cfif Arguments.mode EQ 5>
					<!--- set the right price field --->
					<cfif Session.buyerCat EQ "consumer">
						<cfif Session.currency EQ "gbp">
							<cfset priceType = "jcpric1">
						<cfelseif Session.currency EQ "eur">
							<cfset priceType = "apprice">
						<cfelseif Session.currency EQ "usd">
							<cfset priceType = "usdretail">
						</cfif>
					<cfelseif Session.buyerCat EQ "wholesaler" OR Session.buyerCat EQ "AP">
						<cfif Session.currency EQ "gbp">
							<cfset priceType = "jcpric2">
						<cfelseif Session.currency EQ "eur">
							<cfset priceType = "eurwhlsl">
						<cfelseif Session.currency EQ "usd">
							<cfset priceType = "jcnote09">
						</cfif>
					<cfelseif Session.buyerCat EQ "bulk">
						<cfif Session.currency EQ "gbp">
							<cfset priceType = "jcpric3">
						<cfelseif Session.currency EQ "eur">
							<cfset priceType = "eurbulk">
						<cfelseif Session.currency EQ "usd">
							<cfset priceType = "usdbulk">
						</cfif>
					</cfif>
				</cfif>
				
				<!--- Categories --->
				<!---<cfquery name="cats" datasource="joecool_web">
					select distinct j.jccatname, count(j.jccatname) as sum from jcstktabl  j <cfif Arguments.mode EQ 5>, oldPrices o</cfif>
					<cfif session.buyerCat EQ "consumer">where j.jcid not like '%COM'
					<cfelse>where j.jcid not like '%!_%'escape '!'
					</cfif> 
					and j.jccatname not like ''
					<cfif Arguments.mode EQ 1>
						and j.jcbestsell < '200'
					<cfelseif Arguments.mode EQ 2>
						and j.jcspoff = 'yes'
					<cfelseif Arguments.mode EQ 3>
						and j.jcid >= '51490'
					<cfelseif Arguments.mode EQ 4>
						and j.jcid = "kaiden"
					 <cfelseif Arguments.mode EQ 5>
					 	and o.jcid = j.jcid and o.#priceType# > j.#priceType#
					</cfif>
					group by j.jccatname order by j.jccatname asc
				</cfquery>
				
				<td class="Informal_text_dynamic" align="center">
					<select name="cat" onchange="processing();document.location.href='#pageTargeted#.cfm'+this.options[this.options.selectedIndex].value">
						<option value="?catname=all&rngname=all&items=#urlEncodedFormat(Session.ItemDisplayed)#&page=1&sortby=#urlEncodedFormat(Arguments.sortby)#" <cfif Arguments.cat EQ 'all'> selected="selected"</cfif> >All</option>
						<cfoutput query="cats">
							<option value="?catname=#urlEncodedFormat(cats.jccatname)#&rngname=all&items=#urlEncodedFormat(Session.ItemDisplayed)#&page=1&sortby=#urlEncodedFormat(Arguments.sortby)#" <cfif Arguments.cat EQ '#cats.jccatname#'> selected="selected"</cfif> ><cfif cats.jccatname EQ ''>Other<cfelse>#cats.jccatname#</cfif> (#cats.sum#)</option>
						</cfoutput>
					</select>
				</td>
				
				<!--- Materials --->
				<cfquery name="morechoice" datasource="joecool_web">
					SELECT distinct j.jcmat1, j.jccatname, count(j.jcmat1) as sum
					FROM jcstktabl j <cfif Arguments.mode EQ 5>, oldPrices o</cfif>
					WHERE <cfif Arguments.cat NEQ "all">j.jccatname = '#Arguments.cat#' and</cfif>
					<cfif session.buyerCat EQ "consumer"> j.jcid not like '%COM'
					<cfelse> j.jcid not like '%!_%'escape '!'
					</cfif>
					<cfif Arguments.mode EQ 1>
						and j.jcbestsell < '200'
					<cfelseif Arguments.mode EQ 2>
						and j.jcspoff = 'yes'
					<cfelseif Arguments.mode EQ 3>
						and j.jcid >= '#Application.newItems#'
					<cfelseif Arguments.mode EQ 4>
						and j.jcid = "kaiden"
					 <cfelseif Arguments.mode EQ 5>
						and o.jcid = j.jcid and o.#priceType# > j.#priceType#
					</cfif>
					group by j.jcmat1 order by j.jcmat1 asc
				</cfquery>
				<td class="Informal_text_dynamic" align="center">
					<select name="mat" onchange="processing();document.location.href='#pageTargeted#.cfm'+this.options[this.options.selectedIndex].value">
						<option value="?catname=#urlEncodedFormat(Arguments.cat)#&rngname=all&items=#urlEncodedFormat(Session.ItemDisplayed)#&page=1&sortby=#urlEncodedFormat(Arguments.sortby)#" <cfif Arguments.rng EQ 'all'> selected="selected"</cfif> >All</option>
						<cfoutput query="morechoice">
							<option value="?catname=#urlEncodedFormat(Arguments.cat)#&page=1&rngname=#urlEncodedFormat(morechoice.jcmat1)#&items=#urlEncodedFormat(Session.ItemDisplayed)#&sortby=#urlEncodedFormat(Session.sortBy)#" <cfif Arguments.rng EQ '#morechoice.jcmat1#'> selected="selected"</cfif> >#morechoice.jcmat1#&nbsp;<cfif morechoice.jccatname EQ ''>Other<cfelse>#morechoice.jccatname#</cfif>&nbsp;(#morechoice.sum#)</option>
						</cfoutput>
					</select>
				</td>--->
				
				<!--- Sort by --->
				<cfset Session.sortBy = "#Arguments.sortby#">
				<td class="Informal_text_dynamic" align="center">
					<select name="sort" onchange="processing();document.location.href='#pageTargeted#.cfm'+this.options[this.options.selectedIndex].value">
						<option value="?catname=#urlEncodedFormat(Arguments.cat)#&rngname=#urlEncodedFormat(Arguments.rng)#&items=#urlEncodedFormat(Session.ItemDisplayed)#&page=1&sortby=novelty" <cfif Arguments.sortby EQ 'novelty'> selected="selected"</cfif> >Newest first</option>
						<option value="?catname=#urlEncodedFormat(Arguments.cat)#&rngname=#urlEncodedFormat(Arguments.rng)#&items=#urlEncodedFormat(Session.ItemDisplayed)#&page=1&sortby=highestPrice" <cfif Arguments.sortby EQ 'highestPrice'> selected="selected"</cfif> >Highest Price first</option>
						<option value="?catname=#urlEncodedFormat(Arguments.cat)#&rngname=#urlEncodedFormat(Arguments.rng)#&items=#urlEncodedFormat(Session.ItemDisplayed)#&page=1&sortby=lowestPrice" <cfif Arguments.sortby EQ 'lowestPrice'> selected="selected"</cfif> >Lowest Price first</option>
						<option value="?catname=#urlEncodedFormat(Arguments.cat)#&rngname=#urlEncodedFormat(Arguments.rng)#&items=#urlEncodedFormat(Session.ItemDisplayed)#&page=1&sortby=special" <cfif Arguments.sortby EQ 'special'> selected="selected"</cfif> >Special offers first</option>
						<option value="?catname=#urlEncodedFormat(Arguments.cat)#&rngname=#urlEncodedFormat(Arguments.rng)#&items=#urlEncodedFormat(Session.ItemDisplayed)#&page=1&sortby=bestseller" <cfif Arguments.sortby EQ 'bestseller'> selected="selected"</cfif> >Best sellers first</option>
					</select>
				</td>
				
				<!--- Items per pages --->
				<td class="links_prev_next" align="right">
					<cfif Session.ItemDisplayed EQ 20><span class="thumb_title_style"><u>20</u>
					<cfelse></span><a onclick="processing()" href="#pageTargeted#.cfm?catname=#urlEncodedFormat(Arguments.cat)#&rngname=#urlEncodedFormat(Arguments.rng)#&items=20&page=1&sortby=#urlEncodedFormat(Arguments.sortby)#" class="links_prev_next">20</a>
					</cfif>
					<cfif Session.ItemDisplayed EQ 50><span class="thumb_title_style"><u>50</u></span>
					<cfelse><a onclick="processing()" href="#pageTargeted#.cfm?catname=#urlEncodedFormat(Arguments.cat)#&rngname=#urlEncodedFormat(Arguments.rng)#&items=50&page=1&sortby=#urlEncodedFormat(Arguments.sortby)#" class="links_prev_next">50</a>
					</cfif>
					<cfif Session.ItemDisplayed EQ 100><u class="thumb_title_style">100</u>
					<cfelse><a onclick="processing()" href="#pageTargeted#.cfm?catname=#urlEncodedFormat(Arguments.cat)#&rngname=#urlEncodedFormat(Arguments.rng)#&items=100&page=1&sortby=#urlEncodedFormat(Arguments.sortby)#" class="links_prev_next">100</a>
					</cfif>
					<cfif Session.ItemDisplayed EQ 50000><u class="thumb_title_style">All</u>
					<cfelse><a onclick="processing()" href="#pageTargeted#.cfm?catname=#urlEncodedFormat(Arguments.cat)#&rngname=#urlEncodedFormat(Arguments.rng)#&items=50000&page=1&sortby=#urlEncodedFormat(Arguments.sortby)#" class="links_prev_next">All</a>
					</cfif>
				</td>
			</tr>
			<!---<tr><td colspan="5">&nbsp;</td></tr>--->
			<tr>
				<!--- Show "only in stock" ? --->
				<td class="Informal_text_dynamic" align="left" colspan="5">
					<cfparam name="Session.inStockOnly" default="no">
					<cfif Session.inStockOnly EQ "yes">
						<a onclick="processing()" href="#pageTargeted#.cfm?catname=#urlEncodedFormat(Arguments.cat)#&rngname=#urlEncodedFormat(Arguments.rng)#&items=20&page=1&sortby=#urlEncodedFormat(Arguments.sortby)#&inStockOnly=no" class="links_prev_next">Show all items even if not in stock now</a>
					<cfelse>
						<a onclick="processing()" href="#pageTargeted#.cfm?catname=#urlEncodedFormat(Arguments.cat)#&rngname=#urlEncodedFormat(Arguments.rng)#&items=20&page=1&sortby=#urlEncodedFormat(Arguments.sortby)#&inStockOnly=yes" class="links_prev_next">Show items in stock only</a>
					</cfif>
				</td>
			</tr>
		</table>
		
		<cfif Arguments.mode EQ 4><form><input type="hidden" name="search" value="Session.search" /></form></cfif>
    </cffunction>

Open in new window


Sorry but there are a lot of code commented (mainly the queries to get the page contents) : I have commented them after your sugestions, but I don’t have had time to clean them.

Now the website is mainly more responsive, exeption made of the big pages : bracelets, necklaces, rings (the categories which contains the most products inside) and new items & best sellers.

Hope it could help to resolve this, thanks a lot for your help.
0
 
LVL 24

Expert Comment

by:dgrafx
ID: 39888866
appreciate all the code ...

the reason I asked you to do the #queryname.recordcount# is just to double check how many records are returned.

also can you point me to your most current pagination code.
not sure i understand mysql pagination.

thanks
0
 

Author Comment

by:adam1h
ID: 39888922
Hi dgrafx,

Not sure what you are asking for.

If you want to see just the sql portion who manage pagination, here is it :
... limit #(Arguments.page-1)*Arguments.itemsPerPages#, #Arguments.itemsPerPages#

Open in new window

Where Arguments.page is the asked page (for instance the first page with the first 20 products), -1 because mysql start at 0 ;
Arguments.itemsPerPages is the number of products to display (20 by default) ;

Better with an example : I want to see the second page result, with 20 items on it :
Arguments.pages = 2
Arguments.itemsPerPages = 20
Thus the resulting code is :
limit (2-1)*20, 20
Thus :
limit 20, 20

Is it what you asked ?
0
 
LVL 24

Expert Comment

by:dgrafx
ID: 39888935
yeah ok - much different than sql server - thanks
and each query is outputting 20 records

thanks
0
 
LVL 52

Assisted Solution

by:_agx_
_agx_ earned 300 total points
ID: 39889264
That's a lot of code. I'm not sure I follow it all but ... based on what I've skimmed I think you're still looking at a problem with one or more of the 3 issues we mentioned earlier:

1) Converting query results into a bunch of structures isn't needed and slows things down. It's much faster if you just output the query results directly

2) I still see a few queries run within your output loop.  ie
    <cfquery name="oldprices" datasource="joecool_web">


The more queries you're running per page, the more it'll slow things down.

     
Her eis what is lying under application.allProducts :
Product_collection.cfc, and here is the code it contains.

<!--- retrieve products from database (jcstktabl) --->
<cfquery name="q" datasource="joecool_web">
            select * from jcstktabl order by jcid desc
</cfquery>
            
<!--- create the session struct to keep products --->
<cfset cQueryTool = createObject("component", "queryTool").init(q)>


3) Elsewhere in the code you're using LIMIT, but there you're retrieving ALL records from the table. That's still a bottleneck - especially if you're then converting each row to a structure.

You should really enable debugging on your Test server, so you can get a very quick idea of

         a) Which takes the bulk of the time:  CF code or DB queries
         b) How many queries you're actually running per page
         c) Which queries are taking the most time.
0
 
LVL 24

Expert Comment

by:dgrafx
ID: 39889396
agx - could you explain what you are saying about LIMIT.
I'm not quite sure because of not being familiar with MySql but I've had this feeling that all records are being pulled.
I'm just curious ...

adam - you are still using structures - BIG bottleneck !
0
 
LVL 52

Expert Comment

by:_agx_
ID: 39889786
@dgrafx - Honestly I'm not sure if I'm following all of the code logic correctly. I just noticed one version selecting all records from the jcstktabl table (then converting them to structures) Elsewhere in the code there's a query that uses MySQL's LIMIT to only return a page of records (ie 20). Not sure which is in the current code (or possibly both?).

@Adam - Can't you just run the code on your Test box?  Enable debugging in the CF Admin - and look at the summary stats at the bottom of the page. That would tell you instantly what's chewing up the most time.

(Also, I forgot to reiterate normalizing the database would go a long way to simplifying the code/queries and improving performance. I know it's not something you're going to do right now - but it's definitely part of the problem).
0
 

Author Comment

by:adam1h
ID: 39891415
Hi all,

About the structure, I only launch it at the application start.
Tell me if I’m wrong, but there I convert all products data into a struct in the application scope, then when a product page is displayed, I only query the id that will be shown.
As I only query the id and then use the on memory struct, I think it not slow down the process.
What do you think ?

Then about the query « old prices », I will try to reduce or avoid it. Thanks to point me out this issue.
0
 
LVL 24

Accepted Solution

by:
dgrafx earned 200 total points
ID: 39891597
what i'd like to see you do is just run a query  - no structs no nested queries no nothing else - you will then see that your code will come up to normal speed.

you can then start adding features once you have a solid foundation.
and quite frequently it is the way in which you code features that cause a bottleneck or not.
0
 

Author Comment

by:adam1h
ID: 39892328
Hi dgrafx,

I understand your query, but the problem is that this structure is nested & involved in all the website file.
Thus is not easy to change this & to test.

As this version of the website is active only during the time I will finish the next version, We just want to optimise it, not to remade all.

On other hand, many products pages are now more rapid after I have made the modifications you have both sugested.
The remaining probleem is for some big products categories (necklaces, bracelet & rings) & the best sellers & new items pages.

I think now the trouble is more in the database.
0
 
LVL 52

Expert Comment

by:_agx_
ID: 39896705
Understood, but it's something to consider for the future because the current method of converting everything to structures adds unnecessary complexity and extra o/h.  It's re-doing what a db query does already ;-)

Anyway, did you see my comment above? ie Quickest way to find out what's taking so long is run it on your Test box and check the debugging times.
0
 

Author Comment

by:adam1h
ID: 39896878
Hi agx,

I have seen, but we are on a shared server, we do not have access to the test box
0
 
LVL 52

Expert Comment

by:_agx_
ID: 39897290
Well you should have a separate Test box of your own, so you can test things like this before moving them to Production.  On a Test box you can enable debugging, which is something you generally wouldn't want to do on Production. Failing that, set up a local Dev box with the free Developer version and test it there.
0
 

Author Comment

by:adam1h
ID: 39920327
Hi _agx_ and all,

We have to close this question...All your advices are surely excellent, but it still doesn't fix the problem unfortunately.

How can I give the points ?

Best regards,
Yves
0
 
LVL 24

Expert Comment

by:dgrafx
ID: 39920378
seriously - when you say "it still doesn't fix the problem"
you're not doing what you've been advised to do!
you keep saying that you can't make the changes now but will keep them in mind for the next rewrite.
the decision is yours to not make changes!
you need to view this question as having been answered.

good luck ...
0
 

Author Comment

by:adam1h
ID: 39938950
Dear Dgrafx, _agx_,

I wanted to come back to you on this one.  You were 100% right. we did get rid of the structure and worked over the website and made all changes. It took 2 days but the result is fantastic !

THe website is now working as a bullet and is much more efficient than ever.

So, MANY THANKS FOR THE TIME AND EFFORTS SPENT WITH TRYING TO SOLVE OUR PROBLEM. YOU BOTH WERE RIGHTS.

PLease accept my apologizes for this.

Best regards,
Adam.
0
 
LVL 24

Expert Comment

by:dgrafx
ID: 39939316
cool ...
0
 
LVL 52

Expert Comment

by:_agx_
ID: 39939739
Awesome! Thanks for letting us know.
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

I spent nearly three days trying to figure out how incorporate OAuth in Coldfusion for the Eventful API. Hopefully, this article will allow Coldfusion Programmers to buzz through the API when they need to. Basically, what this script does is authori…
Thoughout my experience working on eCommerce web applications I have seen applications succumbing to increased user demand and throughput. With increased loads the response times started to spike, which leads to user frustration and lost sales. I ha…
Wufoo.com provides powerful tools for surveying targeted groups, and utilizing data from completed surveys to find trends, discover areas of demand or customer expectation, and make business decisions on products or services.
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to choose which pages of your form are visible to your users based on their inputs. The page rules feature provides you with an opportunity to create if:then statements for y…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now