Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Less Graphics Option


808smokey

Recommended Posts

Hi,

 

Does anyone know how to make a link on your site that will give the customer an option to load less/fewer graphics? Mainly for people with dialup connections, that way the page will load faster.

 

Thanks

Link to comment
Share on other sites

You could create an entrance page that had two options, one for dialup and one for broadband. You would then have to create two different sites. Or, if you are up to the coding nightmare, you could make a variable that told whether to load an image or not, then attach that variable to each image. If it was true the image would load, and if it was false the image would not load. You could have text in place of the images. Your best bet, and easiest, is to get a good graphics application (Paint Shop, Photo Shop, Fireworks, etc...) and optimize your images. If you play around you can get an excellent image quality with minimal file size.

Link to comment
Share on other sites

I think I've done what you're looking for. I implemented it on my site, and it really wasn't all that nightmarish. It was a little work, though. Check out my website at Myriad Games, browse into any category, then click the "No Images" link at the top of the product listing. I think that's the kind of thing you're after.

 

How comfortable are you with diving into the code?

Tim

 

Webmaster

www.myriadgames.com

-So Many Games, So Little Time-

Link to comment
Share on other sites

Great idea! Now the 2 dollar question. How did you do it?? And also how did you make the dropdown to display more or less items. Another great idea!

Link to comment
Share on other sites

I got the $3 questions. Will please post the code on how to implement this? That's exactly what I was after.

 

 

Is this the line that does it?

 

for starters at least??

 

Thanks for the help

Link to comment
Share on other sites

Now the 2 dollar question. How did you do it??

In modules/product_listing.php, where you you create the sort heading for each column (around line 105), add the link to the Images column:

    if ( ($column_list[$col] != 'PRODUCT_LIST_BUY_NOW') && ($column_list[$col] != 'PRODUCT_LIST_IMAGE') ) {
     $lc_text = tep_create_sort_heading($HTTP_GET_VARS['sort'], $col+1, $lc_text);
   } elseif($column_list[$col] == 'PRODUCT_LIST_IMAGE') {
     if ( $show_pl_images == 'true') {
       $lc_text = '<a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array( 'x', 'y','show_pl_images')) . 'show_pl_images=false') . '" class="productListing-heading">' . TEXT_IMAGES_OFF . '</a>';
     } else {
       $lc_text = '<a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('x', 'y','show_pl_images')) . 'show_pl_images=true') . '" class="productListing-heading">' . TEXT_IMAGES_ON . '</a>';
     }
   }

 

and where you display the image (around line 204), check whether or not it should actually be displayed:

 

          case 'PRODUCT_LIST_IMAGE':
           $lc_align = 'center';
           if ($show_pl_images == 'true') {
             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>';
             } 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> ';
             }
           } else {
             // alternatively, put some placeholder text here.
             $lc_text = ' ';
           }
           break;

 

That should get the images to show or not. Now, you have to go into includes/application_top.php and create a session variable to remeber if someone wants the images or not. I put this around line 320, after setting the default language:

 

// set display images in product listings
 if (isset($HTTP_GET_VARS['show_pl_images']) && $HTTP_GET_VARS['show_pl_images'] != '' ) {
   $show_pl_images = $HTTP_GET_VARS['show_pl_images'];
   tep_session_register('show_pl_images');
 } elseif (!tep_session_is_registered('show_pl_images')) {
   $show_pl_images = 'true';
   tep_session_register('show_pl_images');
 }

 

So...

Hopefully you can dig through that enough to make it work for you. You'll probably have to modify it some.

 

 

And also how did you make the dropdown to display more or less items.

That was a bit trickier. Well, a lot tricker, actually. I had to modify the split_page_results.php class. It was the same basic idea, though.

 

Hope this helps!

Tim

 

Webmaster

www.myriadgames.com

-So Many Games, So Little Time-

Link to comment
Share on other sites

OK,

 

On my line 64 it has this:

case 'PRODUCT_LIST_BUY_NOW':

        $lc_text = TABLE_HEADING_BUY_NOW;

        $lc_align = 'center';

        break;

    }

 

  if ( ($column_list[$col] != 'PRODUCT_LIST_BUY_NOW') && ($column_list[$col] != 'PRODUCT_LIST_IMAGE') ) {

      $lc_text = tep_create_sort_heading($HTTP_GET_VARS['sort'], $col+1, $lc_text);    }

 

    $list_box_contents[0][] = array('align' => $lc_align,

                                    'params' => 'class="productListing-heading"',

                                    'text' => ' ' . $lc_text . ' ');

 

Is the red text the correct spot to place this:

  if ( ($column_list[$col] != 'PRODUCT_LIST_BUY_NOW') && ($column_list[$col] != 'PRODUCT_LIST_IMAGE') ) {

    $lc_text = tep_create_sort_heading($HTTP_GET_VARS['sort'], $col+1, $lc_text);

  } elseif($column_list[$col] == 'PRODUCT_LIST_IMAGE') {

    if ( $show_pl_images == 'true') {

      $lc_text = '<a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array( 'x', 'y','show_pl_images')) . 'show_pl_images=false') . '" class="productListing-heading">' . TEXT_IMAGES_OFF . '</a>';

    } else {

      $lc_text = '<a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('x', 'y','show_pl_images')) . 'show_pl_images=true') . '" class="productListing-heading">' . TEXT_IMAGES_ON . '</a>';

    }

  }

Thanks for the help
Link to comment
Share on other sites

Hmmm

 

Maybe I'm missing something but I get this error on my product pages...

 

Parse error: parse error in /home/aplusc2/public_html/catalog/includes/modules/product_listing.php on line 78
It also erases the item name, price, etc...

 

Any ideas?? :blink:

Link to comment
Share on other sites

OK, i got the pictures on/off to work correctly, but....... It says "TEXT_IMAGES_OFF" or "TEXT_IMAGES_ON" instead of the way your looks. Do I need to add something else to the english.php file??? Do I have to add something to the english.php file??

 

*EDIT* Sweet I rule!!!!!!!!! :P :P :D :blink:

You have to add the lines in red anywhere in the english.php file.

// text for gender

define('MALE', 'Male');

define('FEMALE', 'Female');

define('MALE_ADDRESS', 'Mr.');

define('FEMALE_ADDRESS', 'Ms.');

 

// text for less images

define('TEXT_IMAGES_OFF', 'Turn Images OFF');

define('TEXT_IMAGES_ON', 'Turn Images ON');

 

// text for date of birth example

define('DOB_FORMAT_STRING', 'mm/dd/yyyy');

 

thanks for the code and help myriadgames

 

Also do you know how to make this work for the main page? (catalog)

Link to comment
Share on other sites

Add defines in english.php

define('TEXT_IMAGES_OFF', 'Images Off');

define('TEXT_IMAGES_ON', 'Images On');

How did you finally get it to work?

Link to comment
Share on other sites

Also do you know how to make this work for the main page? (catalog)

Are you talking about just the "New Items For..." box? Or your header / title bar and specials boxes as well?

Basically anywhere you have images to toggle, make an if statement:

 

if ( $show_pl_images == 'true') {
 // code that shows the image
} else {
 // code that doesn't show the image
}

 

That should do it. If you would like code for a specific place, just let me know.

 

Glad you got it working!

Tim

 

Webmaster

www.myriadgames.com

-So Many Games, So Little Time-

Link to comment
Share on other sites

Well basically I want to have a link in my "top site bar"

Site Map | | Tech Support | | Contact Us | | Less Graphics | Weekly Specials | | Search | | Everything In Stock
and have that link turn off the graphics for "New products for Month" box in the red above. I have it set for 12 pics and 56ker's complain that it takes too long to load for them.

 

Should I just put it in the catalog/products_new.php file?? i'll try it anyways but not sure where to put it.

 

Thanks for the help :)

Link to comment
Share on other sites

You'll want to modify header.php in the includes directory. I've modified my header.php quite a bit, so I'm not sure what line number to give you, maybe around line 80?

 

      <?php if ( $show_pl_images == 'true') { ?>
       <a href="<?php echo tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('show_pl_images')) . 'show_pl_images=false'); ?>" class="headerNavigation"><?php echo HEADER_TITLE_LESS_GRAPHICS; ?></a>  | | 
     <?php } else { ?>
       <a href="<?php echo tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('show_pl_images')) . 'show_pl_images=true'); ?>" class="headerNavigation"><?php echo HEADER_TITLE_MORE_GRAPHICS; ?></a>  | | 
     <?php } ?>

 

That should have the same effect as the link in the products_listing.php module, so both will toggle the images on and off.

 

Oh, and of course define HEADER_TITLE_LESS_GRAPHICS and HEADER_TITLE_MORE_GRAPHICS in your english.php file.

 

Should I just put it in the catalog/products_new.php file?? i'll try it anyways but not sure where to put it.

The images in the New Products for Month are actually in the new_products.php file in the modules directory. The products_new.php page is different. But it might not be a bad idea to toggle the images there, as well.

 

Good luck!

Tim

 

Webmaster

www.myriadgames.com

-So Many Games, So Little Time-

Link to comment
Share on other sites

Well so far no luck (10 minutes maybe) I'll try to get it tomorrow. I put it in the header.php and it will put the link in the page to turn on/off but it won't do anything. Just refreshes the page. I'm going to try and get it to work in just the "New Products" window tomorrow. That's where the pics are that slow 56k's down, I guess??

Link to comment
Share on other sites

  • 4 weeks later...

This modification works great! :P

Only 1 question though:

Is this nifty trick also possible on the new products page [products_new.php] and how to do that if possible ?

 

[sorry, i saw the post above already asked for that, but i guess this still hasn't been done succesfully ????]

Link to comment
Share on other sites

  • 2 weeks later...

OK,

 

I got the less images switch to work in the header.php file :P

 

This code will put the images on/off switch into the header if you have a navigation bar on top. You can still put it in the header without anav bar just put in the code around line 54 or just after the <TITLE> Tags

 

Here's the stuff you have to change:

 

In catalog/includes/headers.php

<A href="http://aplus-computersonline.com/catalog/privacy.php"><FONT face="Arial, Helvetica, Sans-Serif" size="2" color="#ffffff"><b>About A+ Computers |</b></A></FONT>

<A href="http://aplus-computersonline.com/catalog/index.php?cPath=81"><FONT face="Arial, Helvetica, Sans-Serif" size="2" color="#ffffff"><b>Microsoft Xbox |</b></A></FONT>

<?php if ( $show_pl_images == 'true') { ?>

      <a href="<?php echo tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('show_pl_images')) . 'show_pl_images=false'); ?>" class="headerNavigation"><?php echo HEADER_TITLE_LESS_GRAPHICS; ?></a>  | | 

    <?php } else { ?>

      <a href="<?php echo tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('show_pl_images')) . 'show_pl_images=true'); ?>" class="headerNavigation"><?php echo HEADER_TITLE_MORE_GRAPHICS; ?></a>  | | 

    <?php } ?>

The part in red puts the on/off switch in the nav bar.

In the catalog/includes/languages/english.php file you have to add this

// text for less images

define('TEXT_IMAGES_OFF', 'Turn Images OFF');

define('TEXT_IMAGES_ON', 'Turn Images ON');

define('HEADER_TITLE_LESS_GRAPHICS', '<FONT face="Arial, Helvetica, Sans-Serif" size="2" color="#ffffff"><b>Turn Images OFF</b></font>');

define('HEADER_TITLE_MORE_GRAPHICS', '<FONT face="Arial, Helvetica, Sans-Serif" size="2" color="#ffffff"><b>Turn Images ON</font></b>');

?>

The part in red changes the header color, the part in black changes the products page box color. The color="#ffffff" I added because the stylesheet.css calls for a different class than the color I need.

 

Thanks again to myriadgames, he thought of it I just tweaked the code to work on my site. As for the new_products.php and other module boxes I can't get it to work it only shows a parse error :angry: But it will turn on/off everything, like the product listing and all products pages. You can go to my site and see how it works. switch on main page, no effect Switch on all products page, It works It may be redundant to have two switches but after weeks of fooling with it I can't bring myself to delete either :blink:

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...