Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

How do I remove the 'defalult_image'?

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 03-09-2005, 02:32 PM
 
techhead techhead is offline
 

Advanced Member
  
Join Date: Jun 2004
Location: Australia, Melbourne
Posts: 30
 

Default How do I remove the 'defalult_image'?

Some of my products have images and some don't.

What I'm out to do is to only display the images when there is one, but when there isn't one I only want to display the text link without the 'default_image' taking up space.

I would of thought that you could turn this on/off in the config.

any ideas?
__________________
xcart v3.5.8 through to v4.0.14
redhat v9
php v4.3.10
MySQL 4.0.22
Reply With Quote
  #2  
Old 03-09-2005, 04:37 PM
 
techhead techhead is offline
 

Advanced Member
  
Join Date: Jun 2004
Location: Australia, Melbourne
Posts: 30
 

Default

I've found a work around. I replaced the default_image.gif with a transparent gif only 1px high
__________________
xcart v3.5.8 through to v4.0.14
redhat v9
php v4.3.10
MySQL 4.0.22
Reply With Quote
  #3  
Old 03-10-2005, 03:07 AM
 
mffowler mffowler is offline
 

X-Adept
  
Join Date: Mar 2003
Location: Melbourne, Australia
Posts: 811
 

Default

You should use an if/else statement for whether there is a product thumbnail or not. It should either reflect another image (like your transparent one) or ...

- Mike
__________________
4.1.9
Reply With Quote
  #4  
Old 03-10-2005, 01:33 PM
 
techhead techhead is offline
 

Advanced Member
  
Join Date: Jun 2004
Location: Australia, Melbourne
Posts: 30
 

Default

I agree. And that's what I set out to do. I ended up at:
x-cart-directory/image.php

I tried commenting out the following line of code from the file where ever it was called (a bit rough I know) as all of the thumbnails for the products are held in the database. But it had no effect... not sure why... it's something that I'm planning on chasing up and testing further when I find time.
Code:
header("Content-type: image/gif"); func_readfile($default_image, true);
__________________
xcart v3.5.8 through to v4.0.14
redhat v9
php v4.3.10
MySQL 4.0.22
Reply With Quote
  #5  
Old 03-11-2005, 01:29 PM
 
dsparks dsparks is offline
 

Advanced Member
  
Join Date: Nov 2002
Posts: 34
 

Default

I have 2 different answers to solve this issue. The first is the easy way with minimum configuration and little control, and the second is the long way so you can have full control over every category image displayed.

The easy way:

1) Add a record to the table "xcart_config" as follows:

Code:
insert into xcart_config (name,`comment`,value,category,orderby,`type`,defvalue) VALUES ('show_category_image','Show category image','Y','Appearance','1300','checkbox','Y')

2) Modify the file "skin1/customer/main/subcategories.tpl"

Around line 17, find the line:

Code:
{if $tmp} [img]{if $current_category.icon_url}{$current_category.icon_url}{else}{$xcart_web_dir}/icon.php?categoryid={$cat}{/if}[/img] {/if}

and change it to:

Code:
{if $tmp and $config.Appearance.show_category_image eq "Y"} [img]{if $current_category.icon_url}{$current_category.icon_url}{else}{$xcart_web_dir}/icon.php?categoryid={$cat}{/if}[/img] {/if}


That's all...


If you want to change the way the category images are displayed just go to the Administration area and select the General settings / Appearance options and select or deselect the option to Show category image (it should be at the bottom of the page).


With this option selected, all category images will be shown and with it deselected, all category images will not be shown.


>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>


Now, the long way:


1) Add a new field show_image to the table xcart_categories:

Code:
ALTER TABLE `xcart_categories` ADD `show_image` CHAR( 1 ) DEFAULT 'Y' NOT NULL ;


Note: If you want the default option to always start with "No" instead of "Yes" to display category images, then just execute the code below instead:

Code:
ALTER TABLE `xcart_categories` ADD `show_image` CHAR( 1 ) DEFAULT 'N' NOT NULL ;


2) Add a new label lbl_show_image in the Language area:

Go to the Language option and select the language you want to edit. Make sure the Select topic is on the Labels option. Now, go down towards the bottom of the page and add a new label entry.

Code:
Where "Variable" = "lbl_show_image", "Description" = "Show image" and "Value" = "Show image"


3) Then change the following 3 files:

-skin1/customer/main/subcategories.tpl
-skin1/admin/main/category_modify.tpl
-admin/category_modify.php


In the file skin1/customer/main/subcategories.tpl around line 17 change:

Code:
{if $tmp} [img]{if $current_category.icon_url}{$current_category.icon_url}{else}{$xcart_web_dir}/icon.php?categoryid={$cat}{/if}[/img] {/if}

to

Code:
{if $tmp and $current_category.show_image eq "Y"} [img]{if $current_category.icon_url}{$current_category.icon_url}{else}{$xcart_web_dir}/icon.php?categoryid={$cat}{/if}[/img] {/if}



In the file skin1/admin/main/category_modify.tpl around line 72 find the following code:

Code:
{if $file_upload_data.file_path} <TR> <TD align="center"> {$lng.txt_save_category_icon_note} </TD> </TR> {/if} </TABLE> </TD> </TR>


and insert this code right after it:


Code:
<TR> <TD height="10" class="FormButton" nowrap>{$lng.lbl_show_image}:</TD> <TD width="10" height="10"><FONT class="CustomerMessage"></FONT></TD> <TD height="10"> <SELECT name="show_image"> <OPTION value='Y' {if ($current_category.show_image eq 'Y')} selected {/if}>{$lng.lbl_yes}</OPTION> <OPTION value='N' {if ($current_category.show_image eq 'N')} selected {/if}>{$lng.lbl_no}</OPTION> </SELECT> </TD> </TR>


Note: If you want the default option on the add new category screen to always start with "No" instead of "Yes" to display category images, then just insert the code below instead:


Code:
<TR> <TD height="10" class="FormButton" nowrap>{$lng.lbl_show_image}:</TD> <TD width="10" height="10"><FONT class="CustomerMessage"></FONT></TD> <TD height="10"> <SELECT name="show_image"> <OPTION value='N' {if ($current_category.show_image eq 'N')} selected {/if}>{$lng.lbl_no}</OPTION> <OPTION value='Y' {if ($current_category.show_image eq 'Y')} selected {/if}>{$lng.lbl_yes}</OPTION> </SELECT> </TD> </TR>



In the file admin/category_modify.php around line 135 change:

Code:
db_query("UPDATE $sql_tbl[categories] SET category='$category_name', description='$description', meta_descr='$meta_descr', meta_keywords='$meta_keywords', avail='$avail', order_by='$order_by', membership='$cat_membership' WHERE categoryid='$cat'");

to

Code:
db_query("UPDATE $sql_tbl[categories] SET category='$category_name', description='$description', meta_descr='$meta_descr', meta_keywords='$meta_keywords', avail='$avail', order_by='$order_by', membership='$cat_membership', show_image='$show_image' WHERE categoryid='$cat'");


That's it.....

Now you can have full control over what category icons are displayed.

When you go the modify category option there will now be an option for Show image towards the top of the screen, where you can select to allow to display or not display this specific image for this category.

If you have any suggestions, please let me know....
__________________
X-Cart Gold: v4.0.17
Reply With Quote
  #6  
Old 03-11-2005, 03:15 PM
 
dsparks dsparks is offline
 

Advanced Member
  
Join Date: Nov 2002
Posts: 34
 

Default

I will be posting the product image code soon....
__________________
X-Cart Gold: v4.0.17
Reply With Quote
  #7  
Old 03-13-2005, 08:14 PM
 
dsparks dsparks is offline
 

Advanced Member
  
Join Date: Nov 2002
Posts: 34
 

Default

I finally got the code straight for the product default image. I ran into a few issues wih variable scoping.

Anyway...

As I re-did the product code, I also re-did an option for the category code.

The following code changes will allow you to show or not show the default icon image for categories or products. This includes the featured item list, bestsellers etc. I also coded this change to only affect the customer areas, as I usually want to see what is going on into the admin area.


1) Add the following 2 records in the xcart_config table:

Code:
insert into xcart_config (name,`comment`,value,category,orderby,`type`,defvalue) VALUES ('show_default_product_image','Show default product image ','Y','Appearance','5100','checkbox','Y') insert into xcart_config (name,`comment`,value,category,orderby,`type`,defvalue) VALUES ('show_default_category_image','Show default category image ','Y','Appearance','5101','checkbox','Y')


2) Change the file skin1/product_thumbnail.tpl:

from:

Code:
{if $config.Appearance.show_thumbnails eq "Y"}[img]{if $tmbn_url}{$tmbn_url}{else}{if $full_url}{$http_location}{else}{$xcart_web_dir}{/if}/image.php?productid={$productid}{if $file_upload_data.file_path}&tmp=y{/if}{/if}[/img]{/if}

to:


Code:
{insert name="is_product_image_avail" assign="image_avail" productid=$productid variantid=""} {if $image_avail} {if $config.Appearance.show_thumbnails eq "Y"}[img]{if $tmbn_url}{$tmbn_url}{else}{if $full_url}{$http_location}{else}{$xcart_web_dir}{/if}/image.php?productid={$productid}{if $file_upload_data.file_path}&tmp=y{/if}{/if}[/img]{/if} {/if}


3) Change the file skin1/customer/main/subcategories.tpl around line 17:

from:

Code:
{if $tmp} [img]{if $current_category.icon_url}{$current_category.icon_url}{else}{$xcart_web_dir}/icon.php?categoryid={$cat}{/if}[/img] {/if}

to:

Code:
{insert name="is_category_image_avail" assign="image_avail" categoryid=$cat} {if $tmp and $image_avail} [img]{if $current_category.icon_url}{$current_category.icon_url}{else}{$xcart_web_dir}/icon.php?categoryid={$cat}{/if}[/img] {/if}


4) Then add the following code to the end of the file include/func.php:


Code:
# # Check to see if an image is available for a product and wether to use default image or not # function insert_is_product_image_avail($params, &$smarty) { global $config, $sql_tbl, $usertype, $current_area; $use_image = false; if ($current_area == "C" || $usertype == "C") { $productid = $params['productid']; $variantid = $params['variantid']; if (empty($productid)) $productid = ""; if (empty($variantid)) $variantid = ""; $continue_checks = true; if(!empty($variantid)) $dbresult = db_query("SELECT image, image_path FROM $sql_tbl[thumbnails] WHERE productid='$productid' AND variantid = '$variantid'"); if(empty($dbresult)) $dbresult = db_query("SELECT image, image_path FROM $sql_tbl[thumbnails] WHERE productid='$productid' AND variantid = ''"); if (db_num_rows($dbresult)) list($image, $image_path) = db_fetch_row($dbresult); else { if ($config["Appearance"]["show_default_product_image"] == "Y") $use_image = true; $continue_checks = false; } db_free_result($dbresult); if ( $continue_checks == true ) { if ($config["Images"]["thumbnails_location"] == "DB") { if (!empty($image)) $use_image = true; else $no_image_db = true; } if ($config["Images"]["thumbnails_location"] == "FS" || !empty($no_image_db) ) { if (!empty($image_path)) { $use_image = true; $continue_checks = false; } } } if ( $continue_checks == true ) { if (!empty($image_out)) $use_image = true; else { if ($config["Appearance"]["show_default_product_image"] == "Y") $use_image = true; } } } else $use_image = true; return $use_image; }

and

Code:
# # Check to see if an image is available for a category and wether to use default image or not # function insert_is_category_image_avail($params, &$smarty) { global $config, $sql_tbl, $usertype, $current_area; $use_image = false; if ($current_area == "C" || $usertype == "C") { $categoryid = $params['categoryid']; if (empty($categoryid)) $categoryid = 0; $image_out = ""; $image_type = ""; $image_path = ""; $image = ""; $continue_checks = true; if ($config["Images"]["icons_location"] == "FS") $image_field = "image_path"; else $image_field = "image"; $categoryid_path = func_query_first_cell("SELECT categoryid_path FROM $sql_tbl[categories] WHERE categoryid='$categoryid'"); $_cat_sequense = array_reverse(explode("/", $categoryid_path)); foreach ($_cat_sequense as $k=>$v) { $category_icon = func_query_first("SELECT $image_field, image_type FROM $sql_tbl[icons] WHERE categoryid='$v'"); if (!empty($category_icon[$image_field])) { $image_type = $category_icon["image_type"]; $$image_field = $category_icon[$image_field]; break; } } if (empty($image) and empty($image_path)) { if ($config["Appearance"]["show_default_category_image"] == "Y") $use_image = true; $continue_checks = false; } if ($continue_checks == true) { if ($config["Images"]["icons_location"] == "DB") { if (!empty($image)) $image_out = $image; else $no_image_db = true; } if ($config["Images"]["icons_location"] == "FS" || !empty($no_image_db)) { if (!empty($image_path)) { $use_image = true; $continue_checks = false; } } if ($continue_checks == true ) { if (!empty($image_out)) $use_image = true; else { if ($config["Appearance"]["show_default_category_image"] == "Y") $use_image = true; } } } } else $use_image = true; return $use_image; }


That's all...


If you want to change the way the product/category images are displayed just go to the Administration area and select the General settings / Appearance options and select or deselect the options to Show default category image and Show default product image (they should be at the bottom of the page).

This modification will not remove the added space taken up by the image if it were displayed.

If you want to do this, then you will need to change about 15 other files.

Typically, you just need to look for references to the text product_thumbnail.tpl in all of the files and put the following code around where the display table is built to display the image and remove the modification to the file skin1/product_thumbnail.tpl


Code:
{insert name="is_product_image_avail" assign="image_avail" productid=$productid variantid=""} {if $image_avail} *** DO CODE TO DEFINE TABLE AND DISPLAY IMAGE *** {/if}



Let me know if this works for you....
__________________
X-Cart Gold: v4.0.17
Reply With Quote
  #8  
Old 05-03-2005, 06:15 AM
 
zilker zilker is offline
 

Advanced Member
  
Join Date: Feb 2003
Posts: 89
 

Default

Very nice mod. I'm using it on a site I'm putting together right now. I had a problem when trying to use the last part of the code:

Quote:
If you want to change the way the product/category images are displayed just go to the Administration area and select the General settings / Appearance options and select or deselect the options to Show default category image and Show default product image (they should be at the bottom of the page).

This modification will not remove the added space taken up by the image if it were displayed.

If you want to do this, then you will need to change about 15 other files.

Typically, you just need to look for references to the text product_thumbnail.tpl in all of the files and put the following code around where the display table is built to display the image and remove the modification to the file skin1/product_thumbnail.tpl


Code:
{insert name="is_product_image_avail" assign="image_avail" productid=$productid variantid=""} {if $image_avail} *** DO CODE TO DEFINE TABLE AND DISPLAY IMAGE *** {/if}


When I use the insert name and {if} statement outside of the skin1/product_thumbnail.tpl file, it's not working properly and removes thumbnail images from all products, not just those with the default image.

Here is code I use in product.tpl and products.tpl for my thumbnails:

Code:
<table cellpadding="1" cellspacing="0"> <tr><td class="ImgBorder2"> <table cellpadding="5" cellspacing="0"> <tr><td class="ImgBorder1">{include file="modules/Special_Offers/customer/product_offer_thumb.tpl" product=$products[product]}</td></tr> </table> </td></tr> </table> {$lng.lbl_see_details}

That code creates a border around the thumbnails. You can view the following link to see it in action http://www.ezcruiseconnection.com/home.php?cat=9 although when you view it, I'll probably have the "see details" link inside of the border tables. That seems to be the only way I can remove the default images but still have something inside of the tables that don't go away, as seen here http://www.ezcruiseconnection.com/home.php?cat=14.

Other than that - it's very nice and thanks a million for the time you donated to it.
__________________
~zilker

uummm...perhaps you should tell me again.

http://www.designertrends.com
Version 4.0.6
Unix
Reply With Quote
  #9  
Old 05-03-2005, 07:49 AM
 
zilker zilker is offline
 

Advanced Member
  
Join Date: Feb 2003
Posts: 89
 

Default

Well, I fixed it with some bubble gum and duct tape

Here's what I did. I took the tables that created the image border and inserted them into the product_thumbnail.tpl file. Then, I realized that the tables sat in between the url tags that made the image clickable. Since that didn't work out as planned, I was forced to think some more which resulted in another idea. I had to put the url tags inside the tables that I placed in product_thumbnail.tpl.

Since products.tpl and product.tpl both read from the same file and call different variables, the modified code wouldn't pull the image on the product.tpl page. So, I created a new file named product_thumbnail_products.tpl and changed products.tpl to include that new file instead of the original.

Here's what we're looking at:

/product_thumbnail_products.tpl
Code:
{* $Id: product_thumbnail.tpl,v 1.14 2004/06/24 09:53:29 max Exp $ *} {insert name="is_product_image_avail" assign="image_avail" productid="$productid" variantid=""} {if $image_avail} {if $config.Appearance.show_thumbnails eq "Y"} <table cellpadding="1" cellspacing="0"> <tr><td class="ImgBorder2"> <table cellpadding="5" cellspacing="0"> <tr><td class="ImgBorder1"> <A href="product.php?productid={$products[product].productid}&cat={$cat}&page={$navigation_page}{if $featured eq 'Y'}&featured{/if}"> [img]{if $tmbn_url}{$tmbn_url}{else}{if $full_url}{$http_location}{else}{$xcart_web_dir}{/if}/image.php?productid={$productid}{if $file_upload_data.file_path}&tmp=y{/if}{/if}[/img] </A> </td></tr> </table> </td></tr> </table> {/if} {/if}

/product_thumbnail.tpl
Code:
{* $Id: product_thumbnail.tpl,v 1.14 2004/06/24 09:53:29 max Exp $ *} {insert name="is_product_image_avail" assign="image_avail" productid="$productid" variantid=""} {if $image_avail} {if $config.Appearance.show_thumbnails eq "Y"} <table cellpadding="1" cellspacing="0"> <tr><td class="ImgBorder2"> <table cellpadding="5" cellspacing="0"> <tr><td class="ImgBorder1"> [img]{if $tmbn_url}{$tmbn_url}{else}{if $full_url}{$http_location}{else}{$xcart_web_dir}{/if}/image.php?productid={$productid}{if $file_upload_data.file_path}&tmp=y{/if}{/if}[/img] </td></tr> </table> </td></tr> </table> {/if} {/if}

customer/main/products.tpl - only a portion of the file
Code:
{if $active_modules.Special_Offers ne "" and $products[product].have_offers} {include file="modules/Special_Offers/customer/product_offer_thumb.tpl" product=$products[product]} {else} {include file="product_thumbnail_products.tpl" productid=$products[product].productid image_x=$config.Appearance.thumbnail_width product=$products[product].product tmbn_url=$products[product].tmbn_url} {/if}

I also moved the "See details" link and placed it under the short description. That prevents it from being out of place when there isn't a default image.

Like I said, it probably isn't the best way to do it but it works. I haven't tested it in the checkout process but it shouldn't be that difficult to make a small change if something isn't right.
__________________
~zilker

uummm...perhaps you should tell me again.

http://www.designertrends.com
Version 4.0.6
Unix
Reply With Quote
  #10  
Old 07-27-2005, 06:38 AM
 
RBasil RBasil is offline
 

Newbie
  
Join Date: May 2005
Posts: 4
 

Default

Quote:
Originally Posted by dsparks
The easy way:

1) Add a record to the table "xcart_config" as follows:

Code:
insert into xcart_config (name,`comment`,value,category,orderby,`type`,defvalue) VALUES ('show_category_image','Show category image','Y','Appearance','1300','checkbox','Y')

2) Modify the file "skin1/customer/main/subcategories.tpl"

Around line 17, find the line:

Code:
{if $tmp} [img]{if $current_category.icon_url}{$current_category.icon_url}{else}{$xcart_web_dir}/icon.php?categoryid={$cat}{/if}[/img] {/if}

and change it to:

Code:
{if $tmp and $config.Appearance.show_category_image eq "Y"} [img]{if $current_category.icon_url}{$current_category.icon_url}{else}{$xcart_web_dir}/icon.php?categoryid={$cat}{/if}[/img] {/if}

Worked great in 4.013 Pro Thanks!
__________________
---
RBasil
X-Cart 4.0.13 Pro
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 02:23 AM.

   

 
X-Cart forums © 2001-2020