You are viewing this forum as a guest. Login to an existing account, or create a new account, to reply to topics and to create new topics.
Throughout the cart if an item is missing an image then none.png is displayed instead of nothing.
This is not true for "featured products". In that array no image is displayed.
Can the code for featured products be modified to display none.png is there if no image found as well?
Last edited by theblade24 (04-23-2008 17:57:58)
Offline
bump
Offline
The category display view is what is used to show featured products and all of the default displays include logic to show the none image. The test for whether or not an image is present is based on the small image for a product. Unless you've customized the category display and removed the logic for detecting whether or not an image is present the none image should be displayed.
The displays in question are found in admin under Home > ClickCartPro (GBU) > Displays: Skins, Menus, XHTML Includes and Messages > Manage Catalog Product Displays: Category View
Offline
The image is listed in the db for the product.......... but the image is not found on the server.
That is not how the logic works.... it only looks to see if there is a value for an image that is supposed to be there right?
If the value is there and the actual image isn't then it shows nothing.
Any way to get it to display none.png when no image is actually found?
Offline
Not easily. Testing for the presence of the images would add quite a bit of overhead since the logic would be used for every category displayed. There isn't a base method available for testing whether or not a file is present so you'd have to "roll your own".
That said I'll point you towards the file_exists PHP function which you should be able to incorporate into the display you're using. The path to the image is built for you already so it should be pretty easy to use file_exists to find out whether or not the file is actually there and handle accordingly.
Offline
Gave this a try but getting nothing.
<?php if file_exists(/var/www/html/domain/media/ccp0/prodsm/$imgname) { print "<a href='"; print $prodlink; print "' title='"; print $prodname; print "'>"; print $imgtag; print "</a>"; } else { print "Test"; } ?>
Offline
You're probably getting a blank page because of a malformed if statement.
<?php if (file_exists('/var/www/html/domain/media/ccp0/prodsm/' . $imgname)) { print "<a href='"; print $prodlink; print "' title='"; print $prodname; print "'>"; print $imgtag; print "</a>"; } else { print "Test"; } ?>
It also depends where you're putting that too of course.
Offline
ok, got it to work.
In order to display none.png when an image is listed for a product in the database, but the image file is NOT on your server:
In Home > ClickCartPro > Displays: Skins, Menus, XHTML Includes and Messages > Manage Catalog Product Displays: Category View (then the view of your choice)
replace
$imgname = $proddisp['imgsm']; if (empty($imgname)) {$imgname = 'none.png';} $imgwidth = $this->globals('khxc_settings.' . $app . '.imgsizeprodsm'); $imgurl = 'media/' . $app . '/prodsm/' . $imgname; $imgtag = '<img src="' . $imgurl . '" '; if ($imgwidth) {$imgtag .= 'width="' . $imgwidth . '" ';} $imgtag .= 'alt="' . $prodname . '" />'; // +-- // | Print the display. // +-- ?> <div class="center"> <a href="<?php print $prodlink; ?>" title="<?php print $prodname; ?>"><?php print $imgtag; ?></a>
with
$imgname = $proddisp['imgsm']; $imgnamenone = 'none.png'; if (empty($imgname)) {$imgname = 'none.png';} $imgwidth = $this->globals('khxc_settings.' . $app . '.imgsizeprodsm'); $imgurl = 'media/' . $app . '/prodsm/' . $imgname; $imgurlnone = 'media/' . $app . '/prodsm/' . $imgnamenone; $imgtag = '<img src="' . $imgurl . '" '; if ($imgwidth) {$imgtag .= 'width="' . $imgwidth . '" ';} $imgtag .= 'alt="' . $prodname . '" />'; $imgtagnone = '<img src="' . $imgurlnone . '" '; if ($imgwidth) {$imgtagnone .= 'width="' . $imgwidth . '" ';} $imgtagnone .= 'alt="' . $prodname . '" />'; // +-- // | Print the display. // +-- if (empty($imgwidth)) {$imgwidth = 100;} ?> <table class="khxc_ghost"><tr><td class="khxc_ghost" style="width: <?php print $imgwidth; ?>px"> <?php if (file_exists('/var/www/html/prosportsmemorabilia/media/ccp0/prodsm/' . $imgname)) { print "<a href='"; print $prodlink; print "' title='"; print $prodname; print "'>"; print $imgtag; print "</a>"; } else { print "<a href='"; print $prodlink; print "' title='"; print $prodname; print "'>"; print $imgtagnone; print "</a>"; } ?>
Last edited by theblade24 (04-27-2008 13:46:36)
Offline