facelessface Posted January 20, 2006 Posted January 20, 2006 I currently have a currency drop down on my site, to choose between 3 currencies - euros, pounds and usd. I want to replace this drop down with 3 flags -for a more attractive way of displaying the selection. Do you have any ideas how I would go about doing this? Basically all i need is some kind of hyperlink that will modify the php variable which stores the current currency.. thanks mike my sites: ---------- www.preciousmetal-online.co.uk www.liparazzi.com www.yaoh.co.uk
facelessface Posted January 20, 2006 Author Posted January 20, 2006 Anyone have any advice? i'm supposed to be going live with these changes tonight.. my sites: ---------- www.preciousmetal-online.co.uk www.liparazzi.com www.yaoh.co.uk
facelessface Posted January 23, 2006 Author Posted January 23, 2006 still looking for an answer.. I just need a way of changing the current currency via a hyperlink.. Can't be that hard, but am stumped.. :blink: my sites: ---------- www.preciousmetal-online.co.uk www.liparazzi.com www.yaoh.co.uk
buzuc Posted January 23, 2006 Posted January 23, 2006 try to replace you file includes/boxes/currencies.php with that : if (isset($currencies) && is_object($currencies)) { ?> <!-- currencies //--> <tr> <td> <?php $info_box_contents = array(); $info_box_contents[] = array('text' => BOX_HEADING_CURRENCIES); new infoBoxHeading($info_box_contents, false, false); $hidden_get_variables = ''; reset($HTTP_GET_VARS); while (list($key, $value) = each($HTTP_GET_VARS)) { if ( ($key != 'currency') && ($key != tep_session_name()) && ($key != 'x') && ($key != 'y') ) { $hidden_get_variables .= tep_draw_hidden_field($key, $value); } } reset($currencies->currencies); $currencies_array = array(); while (list($key, $value) = each($currencies->currencies)) { $currencies_string .= ' <a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('currency')) . 'currency=' . $key, $request_type) . '">' . $value['title'] . '</a> '; } $info_box_contents = array(); $info_box_contents[] = array('align' => 'center', 'text' => $currencies_string); new infoBox($info_box_contents); ?> </td> </tr> <!-- currencies_eof //--> <?php } ?> this is a "rude" piece of code, to be tested MS2 2.2 fr + Manufacturer copy (5 manufacturers - modified to make it works) + More pics 6 + FCK Editor + zones shipping (modified without weight) + My contribution : Shopping Cart Management for Unique Products I apologize in advance for my poor English I'm French !
facelessface Posted January 26, 2006 Author Posted January 26, 2006 thanks! that did the trick mike :D my sites: ---------- www.preciousmetal-online.co.uk www.liparazzi.com www.yaoh.co.uk
paul_calf Posted February 14, 2006 Posted February 14, 2006 hi i've got the hyperlinks to work but how do i configure it for flag images? incidentally, what would the code be to have a bright flag for the active currency and darkened flags for inactive currencies? (given that i'd need 2 images per flag) hope someone can help paul
Guest Posted February 15, 2006 Posted February 15, 2006 you can find out the selected currency using the $currency global var. The $currencies array contains the value in the title field So you add some code in the currencies while loop: if( $currency == $currencies[$key]['title'] ) { //Display selected } else { // Display non-selected }
paul_calf Posted February 16, 2006 Posted February 16, 2006 hi pal thanks for the reply i've only started getting into php and the above to me is pretty foreign. how do i include it in the code? also how would it know the filename of the flag to display? thanks, paul
Guest Posted February 16, 2006 Posted February 16, 2006 I was under the impression you had something already in place. Well the best way is to create one or two image columns in the currencies table so each currency willl also have an image associated with. Once you have the dbase set then you create a box file with something like this. <?php /* $Id: currencies.php,v 1.16 2003/02/12 20:27:31 hpdl Exp $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2003 osCommerce Released under the GNU General Public License */ if (isset($currencies) && is_object($currencies)) { ?> <!-- currencies //--> <tr> <td> <?php $info_box_contents = array(); $info_box_contents[] = array('text' => BOX_HEADING_CURRENCIES); new infoBoxHeading($info_box_contents, false, false); $hidden_get_variables = ''; reset($currencies->currencies); while (list($key, $value) = each($currencies->currencies) ) { if( $currency == $currencies[$key]['title'] ) { $hidden_get_variables .= ' <a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('language', 'currency')) . 'language=' . $key, $request_type) . '">' . tep_image(DIR_WS_IMAGES . $value['image1'], $value['title']) . '</a> '; else $hidden_get_variables .= ' <a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('language', 'currency')) . 'language=' . $key, $request_type) . '">' . tep_image(DIR_WS_IMAGES . $value['image2'], $value['title']) . '</a> '; } $info_box_contents[] = array('align' => 'center', 'text' => $hidden_get_variables); new infoBox($info_box_contents); ?> </td> </tr> <!-- currencies_eof //--> <?php } ?> You have to get a bit into php and mysql to achieve it though. You could check how the languages box and table is setup to include and display the images.
paul_calf Posted February 16, 2006 Posted February 16, 2006 that's brilliant thanks a lot! i'll have a go with that now :thumbsup:
paul_calf Posted February 16, 2006 Posted February 16, 2006 hi mark i've added everything as you said but i'm getting the error: Parse error: parse error, unexpected T_ELSE in /...../boxes/currencies.php on line 30 any ideas?
Guest Posted February 16, 2006 Posted February 16, 2006 yea there is an extra opening bracket { this: if( $currency == $currencies[$key]['title'] ) { should been if( $currency == $currencies[$key]['title'] ) Also you need to setup the database sql table for the currency to hold images before deploying such code. And this is only a sample. Needs further work to be usable. I just used some code from the languages box to glue it together. Haven't tested it or anything
paul_calf Posted February 16, 2006 Posted February 16, 2006 still same message mate. i've added image1 and image2 fields to currencies, i just copied the same attributes as in languages. filenames added to fields and images uploaded to the images folder. what further work is needed to make it useable?
Guest Posted February 16, 2006 Posted February 16, 2006 Ok,.... here is a box that works I tried it. /* $Id: currencies.php,v 1.16 2003/02/12 20:27:31 hpdl Exp $ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2003 osCommerce Released under the GNU General Public License */ <?php if (isset($currencies) && is_object($currencies)) { ?> <!-- currencies //--> <tr> <td> <?php $info_box_contents = array(); $info_box_contents[] = array('text' => BOX_HEADING_CURRENCIES); new infoBoxHeading($info_box_contents, false, false); reset($currencies->currencies); $currencies_array = array(); while (list($key, $value) = each($currencies->currencies)) { $currencies_array[] = array('id' => $key, 'text' => $value['title']); } $hidden_get_variables = ''; reset($currencies->currencies); while (list($key, $value) = each($currencies->currencies) ) { if( $currency == $key ) $hidden_get_variables .= ' <a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('language', 'currency')) . 'language=' . $key, $request_type) . '">' . tep_image(DIR_WS_IMAGES . $value['image1'], $value['title']) . '</a> '; else $hidden_get_variables .= ' <a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('language', 'currency')) . 'language=' . $key, $request_type) . '">' . tep_image(DIR_WS_IMAGES . $value['image2'], $value['title']) . '</a> '; } $info_box_contents = array(); $info_box_contents[] = array('align' => 'center', 'text' => $hidden_get_variables); new infoBox($info_box_contents); ?> </td> </tr> <!-- currencies_eof //--> <?php } ?>
Guest Posted February 16, 2006 Posted February 16, 2006 also set the currency not the language in the tep_href_link calls from: 'language=' to: 'currency='
paul_calf Posted February 16, 2006 Posted February 16, 2006 i've applied the new code with the currency tep_href_link calls and also added <?php and ?> around the top as it wasn't displaying properly but still no images. the error message has gone and the box is displaying correctly but no flags. i've double checked the database and images folder: image1 and image2 are the field names and the filenames correspond with what's in the images folder but still no go. what do you think?
Guest Posted February 16, 2006 Posted February 16, 2006 have you moded the currencies sql table to add the image column(s)? Where is the sql code you did?
paul_calf Posted February 16, 2006 Posted February 16, 2006 i just inserted 2 fields manually and copied how the languages image field was set out: field | type | collation | attributes | null | default | extra image1 | varchar(64) | latin1_general_ci | | Yes | NULL | image2 | varchar(64) | latin1_general_ci | | Yes | NULL |
Guest Posted February 16, 2006 Posted February 16, 2006 ok have you populated the currency entries with the image filenames? You need to do that too. Then place the images for the currencies in the image directory and test it.
Guest Posted February 16, 2006 Posted February 16, 2006 if you right-click the currency image placeholders what the properties show. Does it show a valid link? you have a url?
Guest Posted February 16, 2006 Posted February 16, 2006 yes you need to change the currencies class. catalog\includes\classes\currencies.php expand the query to include the image1 and image2 columns and for the currencies array just beneath it do the same.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.