News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

[IMPLEMENTED] Problems with shop.browse.php

Started by doorknob, April 20, 2008, 19:43:30 PM

Previous topic - Next topic

doorknob

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:
$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:
require_once( CLASSPATH.'pageNavigation.class.php');
$pagenav = new vmPageNav( $num_rows, $limitstart, $limit );
$tpl->set( 'pagenav', $pagenav );

Delete lines 159 - 160
require_once( CLASSPATH.'pageNavigation.class.php');
$pagenav = new vmPageNav( $num_rows, $limitstart, $limit );

Delete line 218
$tpl->set( 'pagenav', $pagenav );

Delete lines 464 - 468
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:
$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
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
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

Quote from: doorknob 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:
$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:
require_once( CLASSPATH.'pageNavigation.class.php');
$pagenav = new vmPageNav( $num_rows, $limitstart, $limit );
$tpl->set( 'pagenav', $pagenav );

Delete lines 159 - 160
require_once( CLASSPATH.'pageNavigation.class.php');
$pagenav = new vmPageNav( $num_rows, $limitstart, $limit );

Delete line 218
$tpl->set( 'pagenav', $pagenav );

Delete lines 464 - 468
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:
$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
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
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 Studio
http://www.pcinvent.info

pcinvent

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 ;)
PCinvent Studio
http://www.pcinvent.info

gregdev

Quote from: doorknob on April 20, 2008, 19:43:30 PM
I have found a number of problems with shop.browse.php

...

Phil

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

Greg

[tr][td]
[/td][td]
www.plainlycode.com[/td][/tr]
[/table]

bruintje

#4
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

You can located shop.browse.php by:

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

Regards

Richard
www.navigationweb.co.uk