Jump to content
Latest News: (loading..)

mattjt83

♥Ambassador
  • Content count

    566
  • Joined

  • Last visited

  • Days Won

    22

mattjt83 last won the day on July 22 2016

mattjt83 had the most liked content!

About mattjt83

  • Birthday 12/21/1983

Profile Information

  • Real Name
    Matt T
  • Gender
    Male
  • Location
    USA
  • Interests
    Most anything related to computers, websites, and cooking

Recent Profile Visitors

50,905 profile views
  1. The stray </form> tag could cause unforeseen issues and invalidates the html. Not relevant though since you updated the module to a header_tag. I can appreciate what you are doing and I think it's great you're giving back to the community. I have edited your header_tag module so that it is coded according to the proper standards and hopefully doesn't cause issues for users. <?php /* $Id$ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2018 osCommerce Released under the GNU General Public License V1.0 JcM Adaptive Images 16-7-2018 Adaptive Images by Matt Wilcox is licensed under a Creative Commons Attribution 3.0 Unported License. This addon uses the code by MattWilcox/Adaptive-Images from GitHub It is used as supplied and all credit is with original author. All this add-on does is allow you to install in as a module you can turn on and off. */ class ht_jcm_adaptive_images { var $code = 'ht_jcm_adaptive_images'; var $group = 'header_tags'; var $title; var $description; var $sort_order; var $enabled = false; function __construct() { $this->title = MODULE_HEADER_TAGS_JCM_ADAPTIVE_IMAGES_TITLE; $this->description = MODULE_HEADER_TAGS_JCM_ADAPTIVE_IMAGES_DESCRIPTION; if ( defined('MODULE_HEADER_TAGS_JCM_ADAPTIVE_IMAGES_STATUS') ) { $this->sort_order = MODULE_HEADER_TAGS_JCM_ADAPTIVE_IMAGES_SORT_ORDER; $this->enabled = (MODULE_HEADER_TAGS_JCM_ADAPTIVE_IMAGES_STATUS == 'True'); } } function execute() { global $oscTemplate; $output = <<<EOD <script>document.cookie='resolution='+Math.max(screen.width,screen.height)+'; path=/';</script> EOD; $oscTemplate->addBlock($output, $this->group); } function isEnabled() { return $this->enabled; } function check() { return defined('MODULE_HEADER_TAGS_JCM_ADAPTIVE_IMAGES_STATUS'); } function install() { tep_db_query("insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable JcM Adaptive Images Module', 'MODULE_HEADER_TAGS_JCM_ADAPTIVE_IMAGES_STATUS', 'True', 'Do you want to allow images script to be added to the page header?', '6', '1', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())"); tep_db_query("insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Adaptive Images for OcS', 'MODULE_HEADER_TAGS_JCM_ADAPTIVE_IMAGES_DESCRIPTION_STATUS', 'True', 'adaptive images', '6', '0', 'tep_cfg_select_option(array(\'True\'), ', now())"); tep_db_query("insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_HEADER_TAGS_JCM_ADAPTIVE_IMAGES_SORT_ORDER', '0', 'Sort order of display. Lowest is displayed first.', '6', '0', now())"); } function remove() { tep_db_query("delete from configuration where configuration_key in ('" . implode("', '", $this->keys()) . "')"); } function keys() { return array('MODULE_HEADER_TAGS_JCM_ADAPTIVE_IMAGES_STATUS', 'MODULE_HEADER_TAGS_JCM_ADAPTIVE_IMAGES_DESCRIPTION_STATUS', 'MODULE_HEADER_TAGS_JCM_ADAPTIVE_IMAGES_SORT_ORDER'); } } ?>
  2. I looked at the code again and I'm not seeing an opening <form> tag. Also there is zero need for a <form></form> to be used with this snippet or a <div></div>. A header tag would make a lot more sense in this circumstance and would also get the script into the <head> like the author suggests.
  3. @JcMagpie You have a stray </form> in your template file. Also, just a couple thoughts... 1. This probably could/should be a header_tag module rather than a content module since it just inserts a single line of javascript. No use in sticking it inside a <div> and also he recommends it being in the <head> section preferably before any other scripts. 2. I think any file that is using the code from Matt Wilcox should give him credit.
  4. Also it would need different people browsing the site with different devices. If only people with desktops viewed the site maybe the script didn't need to be triggered etc... Try viewing the site on a mobile device and maybe the cache will start to fill up.
  5. @burt Looks like this thread should be frozen: https://forums.oscommerce.com/topic/413005-last-active-oscommerce-team-member/ ????
  6. I think what is happening is the string of installed modules needs to be updated to not include the module you deleted. If you uninstall a module through the admin it updates the configuration table for you but not you may need to do it manually. Login to phpmyadmin and find the configuration table. Search for the rows containing the module keys and delete them. You will also need to update the key that contains the installed modules string. For instance the order totals modules is MODULE_ORDER_TOTAL_INSTALLED and the data in mine is: ot_subtotal.php;ot_discount_coupon.php;ot_redemptions.php;ot_cs_discount.php;ot_shipping.php;ot_rush_order.php;ot_total.php;ot_cs_cash_tendered.php;ot_tax.php. You would need to delete the offending module from that list. I'm not sure what the module is so it might not be in the order total area. It could be in the payment modules etc.... OR maybe just put the files back in place and uninstall it properly from your admin.
  7. @burt Sorry I've been trying to follow along with your work here but am currently buried in Easter orders :) Regarding the hooks and getContent... I like the idea of having a "global" sort of hook in application_top. That way it can take care of all sort of things (ajax calls, and additions to the switch($action)). When you need to add functionality you just have to create and upload your new hook and done. I also like the idea of turning the checkout pages into content modules. It would make things a lot easier to alter for people.
  8. I have developed lots of sites and using a local server for that development made things much simpler. The setup is also quite simple and being able to see changes as you make them without having to FTP files constantly can really make a difference. When you are ready for real-world testing of payment modules you will need to be on the live server of course. To each their own though as I'm sure there are pros/cons of either style. @burt do you still use uniserver?
  9. You could use that to convert your DB for sure. If I was you I would create a subdirectory to test in or even simpler run a local server on your computer to do all of your testing / tweaking on. MAMP is good https://www.mamp.info/en/ The nice thing is that you can test and make whatever changes you want without having to worry about messing up your live site. 1. Download MAMP or an equivalent 2. Download latest BS files 3. Create a new DB and folder for your new site on your local server 4. Create a backup of your current DB and import it into the new DB you just created. 5. Run DB conversion and adjust configuration files so the site knows which DB to connect to etc 6. Figure out what customizations you need to make (SEO URLS, cross selling, etc) I think you will be surprised how much easier it is to make style changes and other alterations with a more modern framework and you will be mobile friendly out of the gate. If you get stuck google is your friend :)
  10. After taking a peak at your site it looks like it is pretty standard. I'm sure there are a few things behind the scenes that would have to be updated but I'd say overall it wouldn't be too difficult to update it to the BS version. The gains would for sure be worth the pain of the update/upgrade.
  11. OK cool. Glad it's working for you
  12. Just so I'm clear, you tried my code or just reverted to the old code?
  13. Maybe this? I haven't tested it but it should work I think <?php /* $Id$ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2014 osCommerce Released under the GNU General Public License */ class ht_grid_list_view { var $code = 'ht_grid_list_view'; var $group = 'footer_scripts'; var $title; var $description; var $sort_order; var $enabled = false; function __construct() { $this->title = MODULE_HEADER_TAGS_GRID_LIST_VIEW_TITLE; $this->description = MODULE_HEADER_TAGS_GRID_LIST_VIEW_DESCRIPTION; if ( defined('MODULE_HEADER_TAGS_GRID_LIST_VIEW_STATUS') ) { $this->sort_order = MODULE_HEADER_TAGS_GRID_LIST_VIEW_SORT_ORDER; $this->enabled = (MODULE_HEADER_TAGS_GRID_LIST_VIEW_STATUS == 'True'); } } function execute() { global $PHP_SELF, $oscTemplate; if (tep_not_null(MODULE_HEADER_TAGS_GRID_LIST_VIEW_PAGES)) { $pages_array = array(); foreach (explode(';', MODULE_HEADER_TAGS_GRID_LIST_VIEW_PAGES) as $page) { $page = trim($page); if (!empty($page)) { $pages_array[] = $page; } } if (in_array(basename($PHP_SELF), $pages_array)) { $grid_list_js = <<<EOD <script> $(function() { if (window.localStorage) { let cc = localStorage['list_grid']; if (cc == 'list') { $('#products .item').removeClass('grid-group-item').addClass('list-group-item'); } else { $('#products .item').removeClass('list-group-item').addClass('grid-group-item'); } $('#list').click(function(event){ event.preventDefault(); $('#products .item').addClass('list-group-item').removeClass('grid-group-item'); localStorage['list_grid'] = 'list'; }); $('#grid').click(function(event){ event.preventDefault(); $('#products .item').removeClass('list-group-item').addClass('grid-group-item'); localStorage['list_grid'] = 'grid'; }); }else{ //cookie fallback $('head').append('<script src="ext/jquery/cookie.js"><\/script>'); try { let cc = $.cookie('list_grid'); if (cc == 'list') { $('#products .item').removeClass('grid-group-item').addClass('list-group-item'); }else{ $('#products .item').removeClass('list-group-item').addClass('grid-group-item'); } $('#list').click(function(event){ event.preventDefault(); $('#products .item').addClass('list-group-item').removeClass('grid-group-item'); $.cookie('list_grid', 'list'); }); $('#grid').click(function(event){ event.preventDefault(); $('#products .item').removeClass('list-group-item').addClass('grid-group-item'); $.cookie('list_grid', 'grid'); }); }catch(error){ console.log(error); } } }); </script> EOD; $oscTemplate->addBlock($grid_list_js . PHP_EOL, $this->group); } } } function isEnabled() { return $this->enabled; } function check() { return defined('MODULE_HEADER_TAGS_GRID_LIST_VIEW_STATUS'); } function install() { tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable Grid List javascript', 'MODULE_HEADER_TAGS_GRID_LIST_VIEW_STATUS', 'True', 'Do you want to enable the Grid/List Javascript module?', '6', '1', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Pages', 'MODULE_HEADER_TAGS_GRID_LIST_VIEW_PAGES', '" . implode(';', $this->get_default_pages()) . "', 'The pages to add the Grid List JS Scripts to.', '6', '4', 'ht_grid_list_view_show_pages', 'ht_grid_list_view_edit_pages(', now())"); tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_HEADER_TAGS_GRID_LIST_VIEW_SORT_ORDER', '0', 'Sort order of display. Lowest is displayed first.', '6', '5', now())"); } function remove() { tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')"); } function keys() { return array('MODULE_HEADER_TAGS_GRID_LIST_VIEW_STATUS', 'MODULE_HEADER_TAGS_GRID_LIST_VIEW_PAGES', 'MODULE_HEADER_TAGS_GRID_LIST_VIEW_SORT_ORDER'); } function get_default_pages() { return array('advanced_search_result.php', 'index.php', 'products_new.php', 'specials.php'); } } function ht_grid_list_view_show_pages($text) { return nl2br(implode("\n", explode(';', $text))); } function ht_grid_list_view_edit_pages($values, $key) { global $PHP_SELF; $file_extension = substr($PHP_SELF, strrpos($PHP_SELF, '.')); $files_array = array(); if ($dir = @dir(DIR_FS_CATALOG)) { while ($file = $dir->read()) { if (!is_dir(DIR_FS_CATALOG . $file)) { if (substr($file, strrpos($file, '.')) == $file_extension) { $files_array[] = $file; } } } sort($files_array); $dir->close(); } $values_array = explode(';', $values); $output = ''; foreach ($files_array as $file) { $output .= tep_draw_checkbox_field('ht_grid_list_view_file[]', $file, in_array($file, $values_array)) . '&nbsp;' . tep_output_string($file) . '<br />'; } if (!empty($output)) { $output = '<br />' . substr($output, 0, -6); } $output .= tep_draw_hidden_field('configuration[' . $key . ']', '', 'id="htrn_files"'); $output .= '<script> function htrn_update_cfg_value() { var htrn_selected_files = \'\'; if ($(\'input[name="ht_grid_list_view_file[]"]\').length > 0) { $(\'input[name="ht_grid_list_view_file[]"]:checked\').each(function() { htrn_selected_files += $(this).attr(\'value\') + \';\'; }); if (htrn_selected_files.length > 0) { htrn_selected_files = htrn_selected_files.substring(0, htrn_selected_files.length - 1); } } $(\'#htrn_files\').val(htrn_selected_files); } $(function() { htrn_update_cfg_value(); if ($(\'input[name="ht_grid_list_view_file[]"]\').length > 0) { $(\'input[name="ht_grid_list_view_file[]"]\').change(function() { htrn_update_cfg_value(); }); } }); </script>'; return $output; }
  14. Also found this https://developer.mozilla.org/en-US/docs/Web/API/Storage/LocalStorage which could be used as a cookie patch for users who can't/don't use localStorage in their browser. if (!window.localStorage) { Object.defineProperty(window, "localStorage", new (function () { var aKeys = [], oStorage = {}; Object.defineProperty(oStorage, "getItem", { value: function (sKey) { return sKey ? this[sKey] : null; }, writable: false, configurable: false, enumerable: false }); Object.defineProperty(oStorage, "key", { value: function (nKeyId) { return aKeys[nKeyId]; }, writable: false, configurable: false, enumerable: false }); Object.defineProperty(oStorage, "setItem", { value: function (sKey, sValue) { if(!sKey) { return; } document.cookie = escape(sKey) + "=" + escape(sValue) + "; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/"; }, writable: false, configurable: false, enumerable: false }); Object.defineProperty(oStorage, "length", { get: function () { return aKeys.length; }, configurable: false, enumerable: false }); Object.defineProperty(oStorage, "removeItem", { value: function (sKey) { if(!sKey) { return; } document.cookie = escape(sKey) + "=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/"; }, writable: false, configurable: false, enumerable: false }); Object.defineProperty(oStorage, "clear", { value: function () { if(!aKeys.length) { return; } for (var sKey in aKeys) { document.cookie = escape(sKey) + "=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/"; } }, writable: false, configurable: false, enumerable: false }); this.get = function () { var iThisIndx; for (var sKey in oStorage) { iThisIndx = aKeys.indexOf(sKey); if (iThisIndx === -1) { oStorage.setItem(sKey, oStorage[sKey]); } else { aKeys.splice(iThisIndx, 1); } delete oStorage[sKey]; } for (aKeys; aKeys.length > 0; aKeys.splice(0, 1)) { oStorage.removeItem(aKeys[0]); } for (var aCouple, iKey, nIdx = 0, aCouples = document.cookie.split(/\s*;\s*/); nIdx < aCouples.length; nIdx++) { aCouple = aCouples[nIdx].split(/\s*=\s*/); if (aCouple.length > 1) { oStorage[iKey = unescape(aCouple[0])] = unescape(aCouple[1]); aKeys.push(iKey); } } return oStorage; }; this.configurable = false; this.enumerable = true; })()); }
  15. @burt Because everyone doesn't use localstorage you might want to check if it's enabled first and use the old code as a backup if it's not. if (window.localStorage) { // use localStorage script }else{ //fallback to cookies here }
×