Post by Tajx » Thu Aug 16, 2012 6:00 pm

HI all,

i want to display products only in Grid view and disable the list display how it possible ?

Please help

New member

Posts

Joined
Wed Aug 15, 2012 4:18 pm

Post by uksitebuilder » Thu Aug 16, 2012 6:38 pm

It will involve editing several template files (basically any tpl file that has the option to switch between list/grid)

It will also involve swapping some code and removing some javascript from the above tpl files.

example on one file catalog/view/theme/default/template/product/category.tpl

find & delete

Code: Select all

<div class="display"><b><?php echo $text_display; ?></b> <?php echo $text_list; ?> <b>/</b> <a onclick="display('grid');"><?php echo $text_grid; ?></a></div>
find

Code: Select all

<div class="product-list">
change to

Code: Select all

<div class="product-grid">
find & delete

Code: Select all

<script type="text/javascript"><!--
function display(view) {
		$('.product-list').attr('class', 'product-grid');
		
		$('.product-grid > div').each(function(index, element) {
			html = '';
			
			var image = $(element).find('.image').html();
			
			if (image != null) {
				html += '<div class="image">' + image + '</div>';
			}
			
			html += '<div class="name">' + $(element).find('.name').html() + '</div>';
			html += '<div class="description">' + $(element).find('.description').html() + '</div>';
			
			var price = $(element).find('.price').html();
			
			if (price != null) {
				html += '<div class="price">' + price  + '</div>';
			}
			
			var rating = $(element).find('.rating').html();
			
			if (rating != null) {
				html += '<div class="rating">' + rating + '</div>';
			}
						
			html += '<div class="cart">' + $(element).find('.cart').html() + '</div>';
			html += '<div class="wishlist">' + $(element).find('.wishlist').html() + '</div>';
			html += '<div class="compare">' + $(element).find('.compare').html() + '</div>';
			
			$(element).html(html);
		});	
					
		$('.display').html('<b><?php echo $text_display; ?></b> <a onclick="display(\'list\');"><?php echo $text_list; ?></a> <b>/</b> <?php echo $text_grid; ?>');
		
		$.cookie('display', 'grid');
	}
}

view = $.cookie('display');

if (view) {
	display(view);
} else {
	display('list');
}
//--></script> 

User avatar
Guru Member

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom

Post by Tajx » Thu Aug 16, 2012 7:10 pm

Thank You so Much Simon!!

New member

Posts

Joined
Wed Aug 15, 2012 4:18 pm

Post by aaron1988 » Mon Oct 15, 2012 5:10 pm

Hey, there is also a CR2 Grid Enabler which means if you enable it then the list view disappears and every thing displays in Grid format.

Check it out here: http://www.opencart.com/index.php?route ... on_id=3204

Aaron

Active Member

Posts

Joined
Thu Jan 27, 2011 10:03 am
Who is online

Users browsing this forum: No registered users and 20 guests