function _product_grid($products, $products_total = null, $page = null, $per_page = null, $keywords = null) { $output = ''; $pages_output = ''; if ($products) { //pagination if ($products_total) { $pagination = new Pagination(array('base_url' => '?page=', 'total_rows' => count($products_total), 'per_page' => $per_page, 'num_links' => 9, 'cur_page' => $page)); if ($pagination->total_rows > $pagination->per_page) { $pages_output .= '<div id="pagination"><p>Pages: ' . str_replace('?page=/', '?page=', $pagination->createLinks()) . '</p></div>'; if ($keywords) { $pages_output = str_replace('?page=', '?keywords=' . $keywords . '&page=', $pages_output); } } } $i = 0; $col_num = 4; $output .= '<table class="ecommerce">'; foreach ($products as $product) { if ($i % $col_num == 0) { if ($i > 1) { $output .= '</tr>'; } $output .= '<tr>'; } $output .= '<td>'; if ($product->image) { $output .= '<a href="/products/' . $product->slug . '"><img src="/public/ecommerce/images/products/' . str_replace('.', '_tn.', $product->image) . '" width="100" /></a><br />'; } $output .= '<a href="/products/' . $product->slug . '">' . $product->title . '</a><br />'; if ($product->price > 0) { $output .= '$' . number_format($product->price, 2); } //$output .= '<br /><a class="more" href="/products/'.$product->slug.'">More Info »</a>'; $output .= '</td>'; $i++; } while ($i % $col_num != 0) { $output .= '<td> </td>'; $i++; } $output .= '</tr></table>'; } $output = $pages_output . $output . $pages_output; if (empty($output)) { $output = '<p>There are no products to display.</p>'; } return $output; }