osCmax v2.5 User Manual
Results 1 to 6 of 6

code reduction/simplification ideas

This is a discussion on code reduction/simplification ideas within the osCmax v1.7 Discussion forums, part of the osCmax v1.7 Forums category; i would like to start a topic about streamlining the code. i feel as though there may be better ways ...

      
  1. #1
    New Member kodersoftware's Avatar
    Join Date
    Oct 2003
    Posts
    17
    Rep Power
    0


    Default code reduction/simplification ideas

    i would like to start a topic about streamlining the code. i feel as though there may be better ways to get the same visual effect on the page with less HTML in the background.

    what spawned this idea is that sometimes I get pages that only get up to the column_right.php and then the code stops there, so it's just a partial page and there is no footer.

    so i started carefully digging and trying to reduce code and simplify. my next posts detail some of my findings and what i did. NOTE: backup your files before you do ANYTHING!

    All additional ideas and help is appreciated!

  2. #2
    New Member kodersoftware's Avatar
    Join Date
    Oct 2003
    Posts
    17
    Rep Power
    0


    Default fully qualified domain name redundancy

    the first thing i notice when i view source is my fully qualified domain name, http://www.moon-dreams.com mentionned over and over and over again. It can be especially terrible on the pages that list a bunch of products, as there is one link assigned to the picture, and then it is repeated again for the product name, and then again for the buy now button, albeit modified a bit. I went into /catalog/includes/functions/html_output.php and altered the tep_href_link function, changing
    Code:
    $link = HTTP_SERVER . DIR_WS_HTTP_CATALOG;
    to
    Code:
    $link = DIR_WS_HTTP_CATALOG;
    The only problem with doing just this is that there are some situations in which the entire url should be sent, like in emails, so you have to check any php code or strings that will send the url to non-relative locations. There may be other things that this is going to screw up, but I'm just finding them as I go along at this point.

    Thoughts

  3. #3
    New Member kodersoftware's Avatar
    Join Date
    Oct 2003
    Posts
    17
    Rep Power
    0


    Default simplify links when listing products

    in all code that lists products in a category or group (not the product detail page), if you keep the default setup for displaying product info, you could also alter the code so that only one link is used between the product image and the product name. where you will alter the code will depend on your installation, but for me i went into /catalog/includes/modules/product_listing_col.php and modified the following 2 sections (the code that was there has a # sign before it and my code below the commented line)
    Code:
    case 'PRODUCT_LIST_NAME':
                $lc_align = '';
                if (isset($HTTP_GET_VARS['manufacturers_id'])) {
                  #$lc_text = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing['products_id']) . '">' . $listing['products_name'] . '</a>';
    			  $lc_text = $listing['products_name'] . '</a>';
                } else {
                  #$lc_text = ' <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">' . $listing['products_name'] . '</a> ';
    			  $lc_text = $listing['products_name'] . '</a> ';
                }
                break;
    and
    Code:
    case 'PRODUCT_LIST_IMAGE':
                $lc_align = 'center';
                if (isset($HTTP_GET_VARS['manufacturers_id'])) {
                  #$lc_text = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing['products_image'], $listing['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a>';
    			  $lc_text = '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'] . '&products_id=' . $listing['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing['products_image'], $listing['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT);
                } else {
                  #$lc_text = ' <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing['products_image'], $listing['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a> ';
    			  $lc_text = ' <a href="' . tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $listing['products_image'], $listing['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT);
                }
                break;

  4. #4
    New Member kodersoftware's Avatar
    Join Date
    Oct 2003
    Posts
    17
    Rep Power
    0


    Default

    another one: is ther any reason at all to use those transparent gifs inside the table cells? couldn't this:
    Code:
    <td><img src="/catalog/images/transprent.gif" alt="" width="1" height="10"></td>
    just be
    Code:
    <td height="10"> </td>
    ?

    anyone... anyone?

  5. #5
    New Member kodersoftware's Avatar
    Join Date
    Oct 2003
    Posts
    17
    Rep Power
    0


    Default

    another idea that would GREATLY reduce the amaount of data to transfer to the client: div's instead of tables for all the inner tables. YES, I know, sometimes tables are just easier. In some cases, I'll use tables for layout. what do ya think? right now, catalog/index.php returns a file that is 41,923 bytes - thats JUST the text. it's a complex page, but i'd like to see that get reduced to about 25,000 bytes max. my site is getting decent volume, so every kb makes a difference and will save me money.

  6. #6
    osCMax Developer

    michael_s's Avatar
    Join Date
    Jul 2002
    Location
    Phoenix, AZ
    Posts
    19,907
    Rep Power
    568


    Default

    kodersoftware, this is a template/design issue mostly. Since BTS is used, it should be fairly easy for you to rebuild the code to your liking.

    The product listing code that you came up with is quite elegant That is a nice one. Thanks for sharing.
    Michael Sasek
    osCMax Developer


    osCmax Installation Service
    - Have our professionals install osCmax on your server - same day service!
    osCmax 2.5 User Manual - the must have beginners guide to osCmax v2.5

    Stay Up To Date with everything osCMax:
    Free osCmax Newsletters - Security notices, New Releases, osCMax News
    osCmax on Twitter - Up to the minute info as it happens. Know it first.

    osCmax Documentation

Similar Threads

  1. Gift voucher balance not being subtracted. Any ideas?
    By malcol27 in forum osCmax v1.7 Discussion
    Replies: 2
    Last Post: 03-22-2006, 06:31 AM
  2. Change Create Order Text "Réduction" and "Li
    By kelly34 in forum osCmax v2 Customization/Mods
    Replies: 3
    Last Post: 08-03-2005, 10:55 AM
  3. Secure admin backend.. Help and/or ideas pleassee
    By edgecrush3r in forum osCMax v1.7 Installation
    Replies: 3
    Last Post: 07-31-2004, 12:52 AM
  4. Any ideas? PAYPAL IPN Not posting! Searched boards.
    By bleu in forum osCmax v1.7 Discussion
    Replies: 5
    Last Post: 06-29-2004, 06:05 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •