Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / Next/Previous button hidden if at end/beginning

Next/Previous button hidden if at end/beginning

Locked

Views: 1,270

Results 1 to 8 of 8
This thread is locked. New replies are disabled.
15 Feb 2007, 4:36 AM
#1
marksimo avatar

marksimo

New Zenner

Join Date:
Feb 2007
Posts:
11
Plugin Contributions:
0

Next/Previous button hidden if at end/beginning

Hi Everyone,

While viewing a product info page, is there a way to deactivate the "next" button if the user is viewing the first product in a category? Conversely, I want to also deactivate the "previous" button if the user is at the last product.

For example, if the user is viewing the first product, he doesn't see a "next" button, only a "previous".

Thanks!

15 Feb 2007, 5:02 AM
#2
afo avatar

afo

Totally Zenned

Join Date:
Aug 2004
Location:
New York City
Posts:
6,800
Plugin Contributions:
0

Re: Next/Previous button hidden if at end/beginning

You seem to be confused. Previous will take the customer to the item BEFORE the item being displayed. If it's the first item, there isn't a previous item. Next will take the customer to the item AFTER the item being displayed. If the last item is being displayed there is no item after it.

15 Feb 2007, 3:28 PM
#3
Kim avatar

Kim

Obaa-san

Join Date:
Jun 2003
Location:
West Coast, North America
Posts:
26,611
Plugin Contributions:
0

Re: Next/Previous button hidden if at end/beginning

Also - depending on how the customer got to the product level they may not land on the first product listed in the category. Say they landed on #3of 6 and went next, next, next they would be on 6of6 but couldn't reach 1of6 without backtracking through the things they have already seen.

15 Feb 2007, 4:28 PM
#4
marksimo avatar

marksimo

New Zenner

Join Date:
Feb 2007
Posts:
11
Plugin Contributions:
0

Re: Next/Previous button hidden if at end/beginning

I realize that it wraps around from last product to first and vice versa. I was basically wondering if there is a way to stop this from happening. I have a site in the works where I DON'T want it to wrap around.

I've set things up so users will always land on newest product when visiting the site and the products are ordered by date added. I don't want them to arrive at the first product page and click "next" and then see the first product, and think that there's nothing new, missing all the other products in between.

15 Feb 2007, 9:05 PM
#5
superprg avatar

superprg

Totally Zenned

Join Date:
Feb 2006
Location:
Chicago
Posts:
1,349
Plugin Contributions:
0

Re: Next/Previous button hidden if at end/beginning

Not very sure if this is the best way to do this
Edit this file:
includes\modules\product_prev_next.php

Find line

if ($previous == -1) $previous = $last;

Replace it with

//if ($previous == -1) $previous = $last;
if ($previous == -1) $previous = $id_array[0];
if($next_item== $id_array[0]) $next_item=$id_array[$counter-1];

Please test it and let me know
Thanks
San

16 Feb 2007, 1:17 AM
#6
marksimo avatar

marksimo

New Zenner

Join Date:
Feb 2007
Posts:
11
Plugin Contributions:
0

Re: Next/Previous button hidden if at end/beginning

Thanks so much! That works great.

Is there any way to hide the "next" / "previous" button if it is at the beginning or end?

16 Feb 2007, 1:51 AM
#7
marksimo avatar

marksimo

New Zenner

Join Date:
Feb 2007
Posts:
11
Plugin Contributions:
0

Re: Next/Previous button hidden if at end/beginning

Never mind, I figured it out.

I changed these two lines:
$previous_button = zen_image_button(BUTTON_IMAGE_PREVIOUS, BUTTON_PREVIOUS_ALT);
$next_item_button = zen_image_button(BUTTON_IMAGE_NEXT, BUTTON_NEXT_ALT);

to

if ($previous != -1){
$previous_button = zen_image_button(BUTTON_IMAGE_PREVIOUS, BUTTON_PREVIOUS_ALT);
}
if($next_item!= $id_array[0]) {
$next_item_button = zen_image_button(BUTTON_IMAGE_NEXT, BUTTON_NEXT_ALT);
}

21 Mar 2007, 10:38 PM
#8
marksimo avatar

marksimo

New Zenner

Join Date:
Feb 2007
Posts:
11
Plugin Contributions:
0

Re: Next/Previous button hidden if at end/beginning

Hey Guys,

I just realized that this method does hide the text so that the button is not visible, but there still is an <a href="whatever"> tag created. It is empty, but still exists. Is there a way to remove the tag too?