Zac123
asked on
stop duplicate prodIDs being added to to listPrepend
hi all,
i'm using this:
<cfparam name="client.recentlyViewe d" default="">
<cfset viewString = url.prodID & "|" & rsgetProduct.product_Name & "|" & request.scndcatName>
<cfset client.recentlyViewed = listPrepend(client.recentl yViewed, viewString)>
to store recently viewed products on my site in the client side cookie.
i then display the recently viewed products to the customer on another page.
the prodID is always unique. how can i stop duplicate prodIDs being added to the 'client' so i downt output dupes?
thanks
i'm using this:
<cfparam name="client.recentlyViewe
<cfset viewString = url.prodID & "|" & rsgetProduct.product_Name & "|" & request.scndcatName>
<cfset client.recentlyViewed = listPrepend(client.recentl
to store recently viewed products on my site in the client side cookie.
i then display the recently viewed products to the customer on another page.
the prodID is always unique. how can i stop duplicate prodIDs being added to the 'client' so i downt output dupes?
thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
perfecto! worked perfectly thanks
its possible they contain commas but unlikely. is this a problem?
Delimiters should never appear in the data or list functions wont' work as you expect. For example ListLen() would tell you this string has 2 elements:
"a|prodName1|catName1,b|pr odName2|ca tName2"
But put a comma in the first product name and it will think it's got 3. So a ListFindNoCase() wouldn't return the right results either ..
"a|prod,Name1|catName1,b|prodName2 |catName2"
Delimiters should never appear in the data or list functions wont' work as you expect. For example ListLen() would tell you this string has 2 elements:
"a|prodName1|catName1,b|pr
But put a comma in the first product name and it will think it's got 3. So a ListFindNoCase() wouldn't return the right results either ..
"a|prod,Name1|catName1,b|prodName2
ASKER
hmm ok thanks. thats worth knowing. not sure what i can do about it though as i dont create the prod names i only collect them from a db.
many thanks
many thanks
Use a different list delimiter. Anything not used in the data should work.
ASKER
>Do any of those values contain contain commas? The list delimiter should never exist in the values you're appending.
its possible they contain commas but unlikely. is this a problem?