Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / Remove "larger image" when no image for product?

Remove "larger image" when no image for product?

Locked

Views: 3,631

Results 1 to 20 of 23
This thread is locked. New replies are disabled.
25 Jul 2009, 1:28 PM
#1
maineiac13 avatar

maineiac13

New Zenner

Join Date:
Sep 2008
Posts:
98
Plugin Contributions:
0

Remove "larger image" when no image for product?

Having searched through these forums, I know there are a number of ways to remove the "larger image" text from the product info page. However, is there a way to remove it only in those cases where the product has no image. That way when there is a product image one can appropriately see a larger image...but when there is no image, the extraneous text (and the accompanying blank pop up window when clicked) can be eliminated thus giving a much cleaner look to product info pages where there are no images.

Thanks

PS - Using 1.38a

25 Jul 2009, 5:21 PM
#2
niccol avatar

niccol

Totally Zenned

Join Date:
Apr 2009
Posts:
2,138
Plugin Contributions:
1

Re: Remove "larger image" when no image for product?

Not quite sure what you want but here is one idea.

What it does is set a new variable ($imageflag) If there is large image the variable is 3. If there is no large image but a medium image the variable is 2. If there is only a small image the variable is one.

It uses this variable to 'decide' whether to print the link. As it is at the moment it will only print the link if there is a appropriate image in the large folder.

The reason I have done it like this is that it is pretty easy to adjust if you want to show the link if there is a medium or large image available. You just need to change an 'if $imageflag = 3' to an 'if $image flag = 3 or if $imageflag=2 ' I don't know how you are set up.

They are not major changes to the files:
tpl_modules_main_product_image.php
main_product_image.php

Both new versions are attached

25 Jul 2009, 6:28 PM
#3
maineiac13 avatar

maineiac13

New Zenner

Join Date:
Sep 2008
Posts:
98
Plugin Contributions:
0

Re: Remove "larger image" when no image for product?

Yes...that works quite well...many thanks. At this point I don't have any medium or large images so the images are showing up...without the text of "larger image" but of course they are still clickable. And where I don't have images, no "larger image" text appears at all. I need to either modify what you did to allow "larger image" with my basic images...or simply put all my images also in the "medium" folder....but in any event this now allows me to gradually add images to the system without worrying that those products without images will look poorly.

So thanks again.

25 Jul 2009, 7:37 PM
#4
niccol avatar

niccol

Totally Zenned

Join Date:
Apr 2009
Posts:
2,138
Plugin Contributions:
1

Re: Remove "larger image" when no image for product?

Well, I have changed it a bit to make it suit you a bit better.

$imageflag is defined as:
0 - if you have not uploaded an image.
1 - if you have uploaded an image but not MED or LRG versions
2 - if you have uploaded a image with a MED version not a LRG version
3 - if you have uploaded a image with a LRG version.

Then I changes the if statement in tpl_modules_product_main_image so that a 'larger image' link was disabled only when you had uploaded no image, i.e. $imageflag=0. But we can change that very easily.

This relies on the fact that your 'no image' image has the default name which is no_picture.gif. If you've changed that we are sunk!

If you want to extend it so that it gets rid of the 'no_image' image as well that is simple. let me know.

25 Jul 2009, 8:43 PM
#5
maineiac13 avatar

maineiac13

New Zenner

Join Date:
Sep 2008
Posts:
98
Plugin Contributions:
0

Re: Remove "larger image" when no image for product?

Thanks for all of this....I need to go start the Barbecue now so I probably won't get back to this til sometime tomorrow :smile:

One thing...at the moment I am not using any image placeholder..i.e. I am not using the no_imag.gif or anything else...but obviously that could be utilized if it would mean that this would work out....but as I said, I will take a look at it tomorrow.

Many thanks!!

25 Jul 2009, 9:14 PM
#6
niccol avatar

niccol

Totally Zenned

Join Date:
Apr 2009
Posts:
2,138
Plugin Contributions:
1

Re: Remove "larger image" when no image for product?

Well, the no_image.gif is set in 'configuration - images - Product Image - No Image picture'

If you set this to no_image.gif then it should all work. The downside is that it will display the no_image image. So, if you don't want to do that then we will just change the code in the files a little bit.

I have had my bbq! Bed is next on the list :smile:

26 Jul 2009, 12:54 PM
#7
maineiac13 avatar

maineiac13

New Zenner

Join Date:
Sep 2008
Posts:
98
Plugin Contributions:
0

Re: Remove "larger image" when no image for product?

I went ahead and set the no image picture to no_picture.gif. However, when I change to the new files that you sent I get text information above the main image as follows:

Base imagename - .jpg
Medium images/imagename.jpg
Large images/imagename.jpg

Imageflag---1

where "imagename" is the name of the image for that particular product.

Where there is no image, I get

Base - NONE
Medium images/NONE
Large images/NONE

Imageflag---1

So I am not sure what is happening here...oh, and where there is no image specified for the product the no_picture.gif image is not appearing...though that image is in my online files.

26 Jul 2009, 1:55 PM
#8
maineiac13 avatar

maineiac13

New Zenner

Join Date:
Sep 2008
Posts:
98
Plugin Contributions:
0

Re: Remove "larger image" when no image for product?

I found out what was causing the text entries....the last echo statement in the main_product_image.php file needed to be commented out as you did in the original version...but not in the new one.

However, even with that correction, I am still getting essentially the same result. If I use the variable 2 or 3 then the words "larger image" do not show up on any of the product main pages. If I use the variable 1, then the words "larger image" show up on all pages....even when there is no image.

26 Jul 2009, 3:34 PM
#9
niccol avatar

niccol

Totally Zenned

Join Date:
Apr 2009
Posts:
2,138
Plugin Contributions:
1

Re: Remove "larger image" when no image for product?

OOOPS forgot to comment out the programmers stuff!!

Well, there is a tip for you :smile:

OK - looks like you found the if conditional statement. The way I sent it to you I think it was configured to be a != statement which means 'does not equal'

So, the way it was sent the logic was :

if $imageflag does not equal 0 then { }

So, what you are saying makes some sense. If you just changed the number and not the != then it is going to be a strange logic. (You need to change the != to a == )

Having said that I would go back to the version of that file that I sent you. The problem we are having is setting the 'no image uploaded' case to 0.

In main_product_image.php you will find a line that reads:

if($products_image_base=='no_picture'){$imageflag=0;}

All we need to do is set that to what ever it is in your set up when there is no image. How do we find out that? Well, we uncomment those programmers lines and see what it says on the screen :smile: By the looks of it it should be 'NONE' the way you have your settings so your code will look like:

if($products_image_base=='NONE'){$imageflag=0;}

That should work out. Let me know.

(Sorry about having made the mistake and left those lines in. But it worked out well because now you know how to find out what the $product_image_base is)

26 Jul 2009, 4:29 PM
#10
maineiac13 avatar

maineiac13

New Zenner

Join Date:
Sep 2008
Posts:
98
Plugin Contributions:
0

Re: Remove "larger image" when no image for product?

Thanks again....I am now understanding the logic of the sequences....but still not having success.

I changed to 'NONE'

I have tried doing the logic both ways...i.e with ==1 and with !=0 but either I get all products with the "larger image" or all products without it.

I mentioned before that when I had set the no image image to be no_picture.gif that the "no picture" image was not showing up. It is possible that when I made earlier changes to my store I may have intentionally done something to make sure that the "no picture" image was not showing up...so I may need now to go back and see what I did and then see if changing that will impact this stuff....ultimately, though I would still prefer to keep the "no picture" image from appearing once I get to the bottom of this.

Thanks for all your help and later today when I get more time I will look into my files to see what may be happening when I allow the no_picture.gif to show up...but it is not showing up even though I have taken the steps in admin for it to show.

By the way...one other thing I am doing which I assume is the right thing...both these new files I have placed in my custom folders rather than in the default folders. I am assuming that is where they are supposed to go.

26 Jul 2009, 4:35 PM
#11
niccol avatar

niccol

Totally Zenned

Join Date:
Apr 2009
Posts:
2,138
Plugin Contributions:
1

Re: Remove "larger image" when no image for product?

Can you do two things:

Firstly, uncomment those programmers bits so all that horrid text appears on the page!

Secondly, send a URL so I can have a look at it.

It works fine on my test server. I'll PM you a link to the pages where it works. And you can say if this is what you want.

26 Jul 2009, 6:27 PM
#12
maineiac13 avatar

maineiac13

New Zenner

Join Date:
Sep 2008
Posts:
98
Plugin Contributions:
0

Re: Remove "larger image" when no image for product?

I got it working....here is what I did.

First, I uncommented the programmer stuff.

Then, as a test I named the "no picture", the actual name of one of my real pictures. This way I could test to see what was happening. Sure enough on that page, the imageflag---0 appeared and the words "larger image" did not appear....On all other pages the imageflag---1 appeared and the words "larger image" was there. So that of course convinced me that this should work if only I could figure out the "name" of my blank images.

Then I thought that maybe instead of using the word 'NONE' which is what was appearing in the text...I should actually USE NOTHING..which is what is really happening with those products which don't have an image...so I changed the code to read:

if($products_image_base==''){$imageflag=0;}

where the '' are two consecutive single quotes not a double quote. thus representing NOTHING...and sure enough it worked. Those pages where there is an image appear properly, and those pages without an image also appear properly...i.e. without the text "larger image."

So thanks very much for working with to get this done.:clap:

26 Jul 2009, 7:03 PM
#13
niccol avatar

niccol

Totally Zenned

Join Date:
Apr 2009
Posts:
2,138
Plugin Contributions:
1

Re: Remove "larger image" when no image for product?

Perfect. Well done :clap:

1 Oct 2009, 3:12 AM
#14
tswift44 avatar

tswift44

New Zenner

Join Date:
Sep 2009
Posts:
13
Plugin Contributions:
0

Re: Remove "larger image" when no image for product?

Nick, I see where you have help this man out a lot. I have been working with your code and got most of it figured out. Looks great.

But I guess I am have a problem because I not want to display a image never. Using your code leaves a place holder.
What am I doing wrong, maybe its my TM template, but all the other suggestion you have given work fine..

Any suggestions would be great..
Tom

1 Oct 2009, 7:10 AM
#15
niccol avatar

niccol

Totally Zenned

Join Date:
Apr 2009
Posts:
2,138
Plugin Contributions:
1

Re: Remove "larger image" when no image for product?

Hi Tom,

If you want to never display an image there are easier ways to do that than this but also this will work!

If you are using a TM template then you need to post a URL so I can have a look and see what is going on.

1 Oct 2009, 12:26 PM
#16
tswift44 avatar

tswift44

New Zenner

Join Date:
Sep 2009
Posts:
13
Plugin Contributions:
0

Re: Remove "larger image" when no image for product?

Thanks Nick for the response.

http://blitzbaydirect.com.

Currently I am using a check mark for the picture, but I prefer to have nothing..

Thanks again for any suggestions.
Tom

1 Oct 2009, 1:10 PM
#17
niccol avatar

niccol

Totally Zenned

Join Date:
Apr 2009
Posts:
2,138
Plugin Contributions:
1

Re: Remove "larger image" when no image for product?

If you really want nothing then find includes/templates/yourtemplate/tpl_product_info_display.php and look for the code that looks like:

<!--bof Main Product Image -->
<?php
  if (zen_not_null($products_image)) {
  ?>
<?php
/**
 * display the main product image
 */
   require($template->get_template_dir('/tpl_modules_main_product_image.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_modules_main_product_image.php'); ?>
<?php
  }
?>
<!--eof Main Product Image-->

And delete it all.

1 Oct 2009, 1:33 PM
#18
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Remove "larger image" when no image for product?

Hmm... Actually, this code already will not display anything at all when there is no product image set:```php

<?php if (zen_not_null($products_image)) { ?> <?php /** * display the main product image */ require($template->get_template_dir('/tpl_modules_main_product_image.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_modules_main_product_image.php'); ?> <?php } ``` Do you have an image for the product and not want to display it on the product info page? Does it perhaps display the "no image" image when there is none set? Then you would want to turn that off in Configuration > Images > Product Image - No Image Status.
1 Oct 2009, 4:09 PM
#19
niccol avatar

niccol

Totally Zenned

Join Date:
Apr 2009
Posts:
2,138
Plugin Contributions:
1

Re: Remove "larger image" when no image for product?

Hmm, that's true. I had kind of assumed that there were images but they weren't needed on the product info page. That's what assumptions do for you...

1 Oct 2009, 6:10 PM
#20
tswift44 avatar

tswift44

New Zenner

Join Date:
Sep 2009
Posts:
13
Plugin Contributions:
0

Re: Remove "larger image" when no image for product?

Understand. Yes I have no Image status set to 0-off and it does not display. But it displays a place holder for and image. I remove a check image on the main page so you can see what I am talking about..

I prefer not to have an image but if I must I will maybe use Stars to rate the product, but that is a lot of work may look nice but very time consuming for 500+ suppliers I have not enter yet..

You thoughts on remove the place hold or at least a way to hide it.
Thanks
Tom