Zen Cart Logo

"View All" link

Views: 24,240

Results 1 to 20 of 46
15 Jun 2006, 9:59 PM
#1
pensive612 avatar

pensive612

Zen Follower

Join Date:
May 2006
Posts:
313
Plugin Contributions:
0

"View All" link

hi everyone,

above the "display items 1-6" link on the top of the product info page... i want to create a link that will display all items in that category on the same page.

"View All Products"

allowing the user to scroll down and view all items.

i'm sure this is possible, just not sure where to start...

any ideas?

16 Jun 2006, 12:01 AM
#2
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: "View All" link

If you want this to be a standard way of viewing your site, you can increase the # of products listed in the admin > config > maxium values> find Products Listing- Number Per Page and set to the number that you want. Now each will display the new # that you have specified.

To custom code this into button would require that you determine what changes that the foregoing makes and use this in your custom code for a button.

16 Jun 2006, 12:06 AM
#3
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: "View All" link

You would need to make an override for the max display so that when selected, it would grab everything and not perform the split page ...

This would take a bit of coding to accomplish, but it can be done ... :smile:

16 Jun 2006, 1:00 AM
#4
pensive612 avatar

pensive612

Zen Follower

Join Date:
May 2006
Posts:
313
Plugin Contributions:
0

Re: "View All" link

thanks guys.

coffee bought...

can someone point me to the right file to override?

i'm thinking, of duplicating and modifying the link for "view products 1-6"

has anyone already done this? i wish i was better with code than i am.

thanks again.

16 Jun 2006, 2:15 AM
#5
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: "View All" link

This code is simplistic but can work ...

Usually, when you hit the Product listing ... the URL reads:

/index.php?main_page=index&cPath=53

This then processes that Category to work with the Maximum display setting ...

However ... if you want to override this, you can do so by creating an override of the file:

/includes/modules/products_listing.php
If you added a link ... for All to generate the URL:
/index.php?main_page=index&cPath=53&override=more

All you need do is edit the products_listing.php to include this IF to control what happens when your link adds that extra paramater ...

Change the line:

  $listing_split = new splitPageResults($listing_sql, MAX_DISPLAY_PRODUCTS_LISTING, 'p.products_id', 'page');

To the new IF statement ...

if ($_GET['override'] == 'more') {
  $max_display_products_listing_override = $db->Execute($listing_sql);
  $max_display_products_listing_override = $max_display_products_listing_override->RecordCount();
  $listing_split = new splitPageResults($listing_sql, $max_display_products_listing_override, 'p.products_id', 'page');
} else {
  $listing_split = new splitPageResults($listing_sql, MAX_DISPLAY_PRODUCTS_LISTING, 'p.products_id', 'page');
}
16 Jun 2006, 2:59 AM
#6
pensive612 avatar

pensive612

Zen Follower

Join Date:
May 2006
Posts:
313
Plugin Contributions:
0

Re: "View All" link

thanks again ajeh... as always, you're the best.

i will let everyone know how it works out.

adam.

17 Jun 2006, 12:03 AM
#7
pensive612 avatar

pensive612

Zen Follower

Join Date:
May 2006
Posts:
313
Plugin Contributions:
0

Re: "View All" link

I really hate to do this, as I appreciate all the help so far...

i cannot figure out how to create the link in php.

everything Ajeh said made perfect sense, and i got it all to work perfectly.. (thank you again, Ajeh) created the if and when manually going to the link it all checks out.

but i need to create the text link. that will say "View All Products" in the product listing page and will link to the 'more - override'

can someone please either let me know the code, or where i can try and learn it. been working for hours on this one...

thanks again.

17 Jun 2006, 12:43 AM
#8
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: "View All" link

Okay ... last peice of the mystery ...

Copy the file:
/includes/templates/templates_default/tpl_modules_product_listing.php

to your overrides directory ...

Find around line 24-25 the code:

<?php if ( ($listing_split->number_of_rows > 0) && ( (PREV_NEXT_BAR_LOCATION == '1') || (PREV_NEXT_BAR_LOCATION == '3') ) ) {
?>

Change to read:

<?php if ( ($listing_split->number_of_rows > 0) && ( (PREV_NEXT_BAR_LOCATION == '1') || (PREV_NEXT_BAR_LOCATION == '3') ) ) {
?>

<div>
<?php
  if ($_GET['override'] == 'more') {
    // Split pages or comment out to not show link when already showing all
    echo ($listing_split->number_of_rows > MAX_DISPLAY_PRODUCTS_LISTING ? '<a href="' . zen_href_link(FILENAME_DEFAULT, 'cPath=' . $_GET['cPath']) . '">' . 'PRODUCT_LISTINGS_SHOW_SPLIT_PAGES_PRODUCTS' . '</a>' : '');
  } else {
    // only show link if more than one page
    echo ($listing_split->number_of_rows > MAX_DISPLAY_PRODUCTS_LISTING ? '<a href="' . zen_href_link(FILENAME_DEFAULT, 'cPath=' . $_GET['cPath'] . '&override=more') . '">' . 'PRODUCT_LISTINGS_SHOW_ALL_PRODUCTS' . '</a>' : '');
  }
?>
</div>

<div id="productsListingTopNumber" class="navSplitPagesResult back"><?php echo $listing_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?></div>
<div id="productsListingListingTopLinks" class="navSplitPagesLinks forward"><?php echo TEXT_RESULT_PAGE . ' ' . $listing_split->display_links(MAX_DISPLAY_PAGE_LINKS, zen_get_all_get_params(array('page', 'info', 'x', 'y', 'main_page'))); ?></div>
<br class="clearBoth" />
<?php
}
?>

Add your defines for the links in your /includes/languages/english/extra_defines ...

17 Jun 2006, 2:44 AM
#9
pensive612 avatar

pensive612

Zen Follower

Join Date:
May 2006
Posts:
313
Plugin Contributions:
0

Re: "View All" link

oh, but the last piece of the mystery created one more...

when i create the define page in my extra definitions folder, how do i tell the link to look at the correct page for the defines?

i will keep researching relentlessly in the meantime...

thanks.

17 Jun 2006, 4:17 AM
#10
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: "View All" link

That is the Magic of Zen ...

Just add the defines into a file in the:

/includes/languages/english/extra_definitions/custom_product_listings_show_all.php

Or any other name that you will remember ...

You can associate the name with the code or use something like:

my_custome_defines.php

What ever works for you ... :)

23 Jun 2006, 9:43 PM
#11
creative avatar

creative

New Zenner

Join Date:
Jul 2005
Posts:
85
Plugin Contributions:
0

Re: "View All" link

Hi, I'm trying to implement a "Show All" link on my products page as well, and have followed these instructions as best I could. I am recieving the following error:

Parse error: syntax error, unexpected T_STRING in /includes/modules/mytemplate/product_listing.php on line 20

This is what I put in my extra defines file, I wasn't sure if I had that quite right.

<?php
//
// Custom Define added by me to allow "Show All" Option to products page.
//

DEFINE('PRODUCT_LISTINGS_SHOW_ALL_PRODUCTS', 'Show All');

?>

The rest I copied and pasted from Ajeh's code on this thread, and put in the appropriate ovveride folders on my server. What am I missing?

23 Jun 2006, 9:58 PM
#12
pensive612 avatar

pensive612

Zen Follower

Join Date:
May 2006
Posts:
313
Plugin Contributions:
0

Re: "View All" link

Creative,

You know, I actually got stopped at the same problem.

I tried that (and got the same error) and everywhere else I could think of.

Could not get the defines to show without an error.

Definitely a question for Ajeh.

I'd love to know too...

sorry, wish i could be more help.

24 Jun 2006, 4:33 AM
#13
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: "View All" link

Do you have the closing ?> at the end of the code?

26 Jun 2006, 3:12 PM
#14
creative avatar

creative

New Zenner

Join Date:
Jul 2005
Posts:
85
Plugin Contributions:
0

Re: "View All" link

I've triple checked all the code, and as far as I can tell, I have everything exactly as described. Any More thoughts?

Using 1.3.0.1
php 4.4.2

11 Jul 2006, 1:48 PM
#15
creative avatar

creative

New Zenner

Join Date:
Jul 2005
Posts:
85
Plugin Contributions:
0

Re: "View All" link

Just bumping this up to see if anyone else has any thoughts on this...

11 Jul 2006, 8:37 PM
#16
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: "View All" link

I will have to go dig up the code again ...

Meanwhile, you might upgrade to v1.3.0.2 as that is the latest release and there are a lot of fixes since v1.3 an v1.3.0.1 ...

11 Jul 2006, 8:49 PM
#17
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: "View All" link

More than likely ... I did not make the code change clear enough for you:

Lines 24-32 read:

<?php if ( ($listing_split->number_of_rows > 0) && ( (PREV_NEXT_BAR_LOCATION == '1') || (PREV_NEXT_BAR_LOCATION == '3') ) ) {
?>
<div id="productsListingTopNumber" class="navSplitPagesResult back"><?php echo $listing_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?></div>
<div id="productsListingListingTopLinks" class="navSplitPagesLinks forward"><?php echo TEXT_RESULT_PAGE . ' ' . $listing_split->display_links(MAX_DISPLAY_PAGE_LINKS, zen_get_all_get_params(array('page', 'info', 'x', 'y', 'main_page'))); ?></div>
<br class="clearBoth" />
<?php
}
?>

Change these to read:

<div>
<?php
  if ($_GET['override'] == 'more') {
    // Split pages or comment out to not show link when already showing all
    echo ($listing_split->number_of_rows > MAX_DISPLAY_PRODUCTS_LISTING ? '<a href="' . zen_href_link(FILENAME_DEFAULT, 'cPath=' . $_GET['cPath']) . '">' . 'PRODUCT_LISTINGS_SHOW_SPLIT_PAGES_PRODUCTS' . '</a>' : '');
  } else {
    // only show link if more than one page
    echo ($listing_split->number_of_rows > MAX_DISPLAY_PRODUCTS_LISTING ? '<a href="' . zen_href_link(FILENAME_DEFAULT, 'cPath=' . $_GET['cPath'] . '&override=more') . '">' . 'PRODUCT_LISTINGS_SHOW_ALL_PRODUCTS' . '</a>' : '');
  }
?>
</div>

<div id="productsListingTopNumber" class="navSplitPagesResult back"><?php echo $listing_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?></div>
<div id="productsListingListingTopLinks" class="navSplitPagesLinks forward"><?php echo TEXT_RESULT_PAGE . ' ' . $listing_split->display_links(MAX_DISPLAY_PAGE_LINKS, zen_get_all_get_params(array('page', 'info', 'x', 'y', 'main_page'))); ?></div>
<br class="clearBoth" />
<?php
}
?>

See if that doesn't correct the error that you are receiving ...

4 Dec 2006, 11:23 PM
#18
buzzville avatar

buzzville

New Zenner

Join Date:
May 2006
Posts:
87
Plugin Contributions:
0

Re: "View All" link

I've been trying to tackle this same customization, but without any luck (no surprises there given that I have no idea what I'm doing!). I made the changes to the product_listing.php file as suggested, and all was fine. But, when I went on to make the changes to the tpl_modules_product_listing.php file, I get this error:

Parse error: parse error, unexpected '}' in /home/content/S/y/t/SyteGod/html/includes/templates/superbuzzy/templates/tpl_modules_product_listing.php on line 41

I've upgraded to 1.3.6, so I'm wondering if some of the language has changed since then? Or perhaps it's just that I'm clueless! This feature isn't a necessity for me, but it would be a really nice addition. I'd appreciate any help at all!

5 Dec 2006, 12:04 AM
#19
pensive612 avatar

pensive612

Zen Follower

Join Date:
May 2006
Posts:
313
Plugin Contributions:
0

Re: "View All" link

It should work just fine in 1.36.

If you're getting a parse error, there's something missing in the code. Missing one paranthesis, or anything will make it fail.

Double check that you're copying and pasting the exact text one more time... if it still doesn't work out for you... PM me a copy of the file and i'll code compare it with mine...

hope all is good.

6 Dec 2006, 11:38 AM
#20
jakedownhere avatar

jakedownhere

New Zenner

Join Date:
Aug 2006
Posts:
38
Plugin Contributions:
0

Re: "View All" link

Found an error in the coding supplied to change to showall in a category on one page versus multiple pages:

echo ($listing_split->number_of_rows > MAX_DISPLAY_PRODUCTS_LISTING ? '<a href="' . zen_href_link(FILENAME_DEFAULT, 'cPath=' . $_GET['cPath']) . '">' . 'PRODUCT_LISTINGS_SHOW_SPLIT_PAGES_PRODUCTS' . '</a>' : '');

And that really needs to be

echo ($listing_split->number_of_rows > MAX_DISPLAY_PRODUCTS_LISTING ? '<a href="' . zen_href_link(FILENAME_DEFAULT, 'cPath=' . $_GET['cPath']) . '">' . PRODUCT_LISTINGS_SHOW_SPLIT_PAGES_PRODUCTS . '</a>' : '');

And the other line...

echo ($listing_split->number_of_rows > MAX_DISPLAY_PRODUCTS_LISTING ? '<a href="' . zen_href_link(FILENAME_DEFAULT, 'cPath=' . $_GET['cPath'] . '&override=more') . '">' . 'PRODUCT_LISTINGS_SHOW_ALL_PRODUCTS' . '</a>' : '');

Really needs to be

echo ($listing_split->number_of_rows > MAX_DISPLAY_PRODUCTS_LISTING ? '<a href="' . zen_href_link(FILENAME_DEFAULT, 'cPath=' . $_GET['cPath'] . '&override=more') . '">' . PRODUCT_LISTINGS_SHOW_ALL_PRODUCTS . '</a>' : '');

Otherwise, it doesn't look up the strings to replace with the constants. It thinks the constants are the strings...

Just thought I'd point this out for others who may be searching for this, like I was this morning :)

Thanks!