[perl] # bestsellers multi-product page urlparams qw( CATEGORY_ID ); $COLUMNS_PER_PAGE = 2; $CATEGORY_ID ||= 'CAT13875'; # bestsellers 200806 #category info $category = $request->get( 'Category', CATEGORY_ID => $CATEGORY_ID ); $request->internal_redirect( '/home.tmpl' ) unless ref($category); @catstack = $category->catstack; $supercat = shift @catstack; $request->internal_redirect( '/home.tmpl' ) unless ref($supercat); $supercat_basename = $supercat->basename; print STDERR "bs supercat basename: $supercat_basename\n"; $supercat_basename = 'bestsellers'; @products = $category->products; print STDERR "bs products: " . scalar( @products ) . "\n"; #urls $URL = $request->get( 'URL' ); ''; [/perl] [perl]include('/templates/includes/head_common.tmpl')[/perl] [perl]include('/templates/includes/setStyleSheet.tmpl')[/perl]
[perl]include('/templates/includes/global.tmpl', supercat => 'bestsellers')[/perl] [perl]include('/templates/includes/global_shim.tmpl')[/perl] }; } $OUT .= q{} . join( $intercolumn_spacer, @TABLE_CELL ) . q{}; [/perl]
[perl]include('/templates/includes/leftnav_merch_window.tmpl', CATEGORY_ID => $CATEGORY_ID );[/perl] [perl]include('/templates/includes/subnav.tmpl', supercat => $supercat )[/perl]
[perl]include('/templates/includes/leftnav_proddir.tmpl', section => 'bestsellers')[/perl] }; sub render_product { my $product = shift; my $column = shift; my $row = shift; my $count = ($row-1)*$COLUMNS_PER_PAGE + $column; my $product_image = $product->SMALL_IMAGE; my $product_image_html_imgszie = $product->SMALL_IMAGE_HTML_IMGSIZE; my $product_namestring = $product->PRODUCT_NAME; my $product_subheading = $product->SUB_HEADING; $product_namestring .= ($product_subheading) ? qq{
$product_subheading} : ''; $product_subline = $product->SUBLINE; my $product_url = $product->url; my $product_description = $product->SHORT_DESC; my $showextras = 1; my $out = qq{
[perl] # column-based layout with order of products zig-zagging down the page from left to right # re-order the products for iteration over columns use integer; $rows = scalar(@products) / $COLUMNS_PER_PAGE; $rows++ if (scalar(@products)) % $COLUMNS_PER_PAGE; no integer; for ($row = 1; $row < $rows; $row++) { push @left_products, $products[2*($row-1)]; push @right_products, $products[2*$row-1]; } push @left_products, $products[2*($rows-1)]; push @right_products, $products[2*$rows-1] if ref($products[2*$rows-1]); @products = (@left_products, @right_products); $empty_cell = q{
}; $interrow_spacer = q{
}; $intercolumn_spacer = q{
}; if ($product_namestring && $showextras) { $out .= qq{ }; } if ($product_subline && $showextras) { $out .= qq{ }; } $out .= qq{
$product_namestring
$product_subline
$product_description
}; $out; } @TABLE_CELLS = (); for ($column = 1; $column <= $COLUMNS_PER_PAGE; $column++) { @COLUMN_CELLS = (); for( $row = 1; $row <= $rows; $row++ ) { $product = shift @products; if (ref($product)) { push @COLUMN_CELLS, render_product( $product, $column, $row ); } else { push @COLUMN_CELLS, $empty_cell } } unshift @COLUMN_CELLS, q{
} if ($column == $COLUMNS_PER_PAGE); push @TABLE_CELL, q{
}. join( $interrow_spacer, @COLUMN_CELLS ) . q{
[perl]include('/templates/includes/footer.tmpl', SECTION => '')[/perl]