Author Topic: [IMPLEMENTED] Problems with shop.browse.php  (Read 22317 times)

doorknob

  • Jr. Member
  • **
  • Posts: 151
[IMPLEMENTED] Problems with shop.browse.php
« on: April 20, 2008, 19:43:30 pm »
I have found a number of problems with shop.browse.php

1 The developer's manual indicates that $product_url is available in the browse templates. This is not so, the following lins should be inserted around line 445:
Code: [Select]
$products[$i]['product_url'] = $db_browse->f("product_url");
2 The manual also makes reference to 'product_available_date'. This should be amended to 'product_availability_date' (p14).

3 There is a problem with the way in which the $pagenav object is instantiated. The object reference is needed in both browse_orderbyform.php and browse_pagenav.php and is selectively instantiated prior to browse_orderbyform.php (the table header) and then instantiated (except if already instantiated earlier) prior to browse_pagenav.php (the table footer). There are two issues with this
a) The code is unnecessarily complicated. The object is always instantiated eventually and so there is no reason to take a complicated approach.
b) The logic used to decide whether to instantiate the object prior to browse_orderbyform.php is flawed. The object is only instantiated if the count of records reaches a specific threshold to justify showing the limit box and/or the navigation buttons. However, simply displaying the count of records being displayed also requires the object to be instantiated, regardless of the number of records. The solution is simple:
Insert the following after line 153:
Code: [Select]
require_once( CLASSPATH.'pageNavigation.class.php');
$pagenav = new vmPageNav( $num_rows, $limitstart, $limit );
$tpl->set( 'pagenav', $pagenav );
Delete lines 159 - 160
Code: [Select]
require_once( CLASSPATH.'pageNavigation.class.php');
$pagenav = new vmPageNav( $num_rows, $limitstart, $limit );
Delete line 218
Code: [Select]
$tpl->set( 'pagenav', $pagenav );
Delete lines 464 - 468
Code: [Select]
if( !isset($pagenav) ) {
require_once( CLASSPATH.'pageNavigation.class.php');
$pagenav = new vmPageNav( $num_rows, $limitstart, $limit);
}
$tpl->set( 'pagenav', $pagenav );

4 For the header, a variable ($show_top_navigation) is created to indicate whether to show the limit box and the navigation buttons. For the footer, it is assumed that the navigation buttons will be shown and a separate variable ($show_limitbox) is used to indicate whether the limit box should be shown. The display of the limit box in the header of the footer should be determined by whether it is appropriate (i.e. more than 5 items) and the display of the navigation buttons should be determined by the number of pages (i.e. more than one). By making both these variables available before the header is produced, the code can be made simpler and more reliable.
Insert the following after line 153:
Code: [Select]
$show_limitbox = ( $num_rows > 5 && @$_REQUEST['output'] != "pdf" );
$tpl->set( 'show_limitbox', $show_limitbox );
$show_top_navigation = ( PSHOP_SHOW_TOP_PAGENAV =='1' && $num_rows > $limit );
$tpl->set( 'show_top_navigation', $show_top_navigation );
Delete lines 215 - 222
Code: [Select]
if( PSHOP_SHOW_TOP_PAGENAV =='1' && ($num_rows > $limit || $num_rows > 5)) {
$tpl->set( 'show_top_navigation', true );
$tpl->set( 'search_string', $search_string );
$tpl->set( 'pagenav', $pagenav );
}
else {
$tpl->set( 'show_top_navigation', false );
}
Delete lines 470 - 474
Code: [Select]
if( $num_rows > 5 && @$_REQUEST['output'] != "pdf") {
$tpl->set( 'show_limitbox', true );
} else {
$tpl->set( 'show_limitbox', false );
}
This is based on the nighty build from today (20/4/2008) and tested on J1.5.2
Phil

pcinvent

  • Beginner
  • *
  • Posts: 19
    • PCinvent Studio
Re: Problems with shop.browse.php
« Reply #1 on: June 19, 2008, 08:48:49 am »
I have found a number of problems with shop.browse.php
1 The developer's manual indicates that $product_url is available in the browse templates. This is not so, the following lins should be inserted around line 445:
Code: [Select]
$products[$i]['product_url'] = $db_browse->f("product_url");
2 The manual also makes reference to 'product_available_date'. This should be amended to 'product_availability_date' (p14).
3 There is a problem with the way in which the $pagenav object is instantiated. The object reference is needed in both browse_orderbyform.php and browse_pagenav.php and is selectively instantiated prior to browse_orderbyform.php (the table header) and then instantiated (except if already instantiated earlier) prior to browse_pagenav.php (the table footer). There are two issues with this
a) The code is unnecessarily complicated. The object is always instantiated eventually and so there is no reason to take a complicated approach.
b) The logic used to decide whether to instantiate the object prior to browse_orderbyform.php is flawed. The object is only instantiated if the count of records reaches a specific threshold to justify showing the limit box and/or the navigation buttons. However, simply displaying the count of records being displayed also requires the object to be instantiated, regardless of the number of records. The solution is simple:
Insert the following after line 153:
Code: [Select]
require_once( CLASSPATH.'pageNavigation.class.php');
$pagenav = new vmPageNav( $num_rows, $limitstart, $limit );
$tpl->set( 'pagenav', $pagenav );
Delete lines 159 - 160
Code: [Select]
require_once( CLASSPATH.'pageNavigation.class.php');
$pagenav = new vmPageNav( $num_rows, $limitstart, $limit );
Delete line 218
Code: [Select]
$tpl->set( 'pagenav', $pagenav );
Delete lines 464 - 468
Code: [Select]
if( !isset($pagenav) ) {
require_once( CLASSPATH.'pageNavigation.class.php');
$pagenav = new vmPageNav( $num_rows, $limitstart, $limit);
}
$tpl->set( 'pagenav', $pagenav );
4 For the header, a variable ($show_top_navigation) is created to indicate whether to show the limit box and the navigation buttons. For the footer, it is assumed that the navigation buttons will be shown and a separate variable ($show_limitbox) is used to indicate whether the limit box should be shown. The display of the limit box in the header of the footer should be determined by whether it is appropriate (i.e. more than 5 items) and the display of the navigation buttons should be determined by the number of pages (i.e. more than one). By making both these variables available before the header is produced, the code can be made simpler and more reliable.
Insert the following after line 153:
Code: [Select]
$show_limitbox = ( $num_rows > 5 && @$_REQUEST['output'] != "pdf" );
$tpl->set( 'show_limitbox', $show_limitbox );
$show_top_navigation = ( PSHOP_SHOW_TOP_PAGENAV =='1' && $num_rows > $limit );
$tpl->set( 'show_top_navigation', $show_top_navigation );
Delete lines 215 - 222
Code: [Select]
if( PSHOP_SHOW_TOP_PAGENAV =='1' && ($num_rows > $limit || $num_rows > 5)) {
$tpl->set( 'show_top_navigation', true );
$tpl->set( 'search_string', $search_string );
$tpl->set( 'pagenav', $pagenav );
}
else {
$tpl->set( 'show_top_navigation', false );
}
Delete lines 470 - 474
Code: [Select]
if( $num_rows > 5 && @$_REQUEST['output'] != "pdf") {
$tpl->set( 'show_limitbox', true );
} else {
$tpl->set( 'show_limitbox', false );
}
This is based on the nighty build from today (20/4/2008) and tested on J1.5.2
Phil

Thank you so much for pointing out these bug. I've just tried to follow the manual to echo $product_available_date in browse page and have nothing return.
Since you had report the right variable is "product_availability_date", I will now have a clue to take a look for shop.browse.php.
Again, thanks!

pcinvent

  • Beginner
  • *
  • Posts: 19
    • PCinvent Studio
Re: Problems with shop.browse.php
« Reply #2 on: June 19, 2008, 09:05:56 am »
FYI

I post the fix of product_available_date in browse page Bug in this post here:
http://forum.virtuemart.net/index.php?topic=41962 ;)

gregdev

  • Full Member
  • ***
  • Posts: 968
    • PlainlyCode
Re: Problems with shop.browse.php
« Reply #3 on: July 09, 2008, 05:20:32 am »
I have found a number of problems with shop.browse.php

...

Phil

Thanks Phil! These are implemented in SVN rev. 1456.

Greg

bruintje

  • Beginner
  • *
  • Posts: 3
Re: [IMPLEMENTED] Problems with shop.browse.php
« Reply #4 on: October 21, 2011, 13:20:33 pm »
Hi,

I would be very greatfull if you tell me where i can find the page "shop.browse.php".

I think my problem is located there too.
My shop keeps changing the availability_date to 2020-12-11, even if i set all products to today's date.

Thanks
bruno

Update:I found the page but the solution above didn't helped me

ingharic

  • Beginner
  • *
  • Posts: 30
Re: [IMPLEMENTED] Problems with shop.browse.php
« Reply #5 on: January 22, 2012, 22:34:42 pm »
You can located shop.browse.php by:

/administrator/components/com_virtuemart/html/shop.browse.php

Regards

Richard
www.navigationweb.co.uk