Hi all,
I’d like to pass an extra parameter through the querystring. The querystring will be hardcoded in a non-cscart page, and it should look like this:
[url]http://example.com/store/index.php?[/url]
dispatch=products.view&product_id=999&shade_id=2
The question becomes: How do I pick this value up from within a cscart template? I only need to write the value into the page, as javascript will do the rest.
Any idea is welcome.
Thank you in advance.
Update:
Running cscart 2.0.14
Nevermind. I just parsed $config.current_url with javascript.
If you wouldn’t mind sharing, I’m interested in your solution.
thanks,
Glen
Sure:
I am looking for the value of the variable “shade” in the querystring:
first, get the url:
var current_url = '{/literal}{$config.current_url}{literal}';
Then parse the url
var shade = '0';
start_t = current_url.indexOf('&shade=')
if (start_t >-1) {
//alert ('start_t: ' + start_t);
start_e = current_url.indexOf('=', start_t);
//alert('start_e: ' + start_e );
// get rest of string after the = sign
url_rest = current_url.substring(start_e+1);
//alert('url_rest; ' + url_rest);
start_e = url_rest.indexOf('&');
//alert('start_e: ' + start_e);
if (start_e == -1) {
shade = url_rest;
}
else {
shade = url_rest.substring(0,start_e);
}
}
The variable ‘shade’ will be a string.
The //alerts can be used to debug, and can be dropped later.
Hope this helps.