Post by PlusCybernet » Sat Jan 07, 2012 5:19 pm

Hello,

I'm using OC Version 1.5.1.3.

Can someone guide me to completely hide "List" view from all pages like Category, Search Result, etc. etc.

Thanks,
Ashish Verma

User avatar
Active Member

Posts

Joined
Sun Dec 25, 2011 12:01 pm

Post by inactiveaccount9912 » Sat Jan 07, 2012 7:04 pm

For category page(the others are similar):

Edit the file catalog/view/theme/yourtheme/template/product/category.tpl

Find and delete the line:
<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>
Then find the line:
<div class="product-list">
and change it into:

Code: Select all

 <div class="product-grid">
And then , from the same file you should also delete the javascript for the grid/list view as its not needed anymore.

So delete:

Code: Select all

<script type="text/javascript"><!--
function display(view) {
	if (view == 'list') {
		$('.product-grid').attr('class', 'product-list');
		
		$('.product-list > div').each(function(index, element) {
			html  = '<div class="right">';
			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>';
			html += '</div>';			
			
			html += '<div class="left">';
			
			var image = $(element).find('.image').html();
			
			if (image != null) { 
				html += '<div class="image">' + image + '</div>';
			}
			
			var price = $(element).find('.price').html();
			
			if (price != null) {
				html += '<div class="price">' + price  + '</div>';
			}
					
			html += '  <div class="name">' + $(element).find('.name').html() + '</div>';
			html += '  <div class="description">' + $(element).find('.description').html() + '</div>';
			
			var rating = $(element).find('.rating').html();
			
			if (rating != null) {
				html += '<div class="rating">' + rating + '</div>';
			}
				
			html += '</div>';

						
			$(element).html(html);
		});		
		
		$('.display').html('<b><?php echo $text_display; ?></b> <?php echo $text_list; ?> <b>/</b> <a onclick="display(\'grid\');"><?php echo $text_grid; ?></a>');
		
		$.cookie('display', 'list'); 
	} else {
		$('.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>

Expert Member

Posts

Joined
Fri May 14, 2010 2:36 am

Post by PlusCybernet » Sat Jan 07, 2012 7:46 pm

Yes, it's done. Thank you for your support.

User avatar
Active Member

Posts

Joined
Sun Dec 25, 2011 12:01 pm

Post by prolitekeiran » Thu Dec 25, 2014 1:40 pm

Came across this issue with Campion theme using 1.5.6.4.

Some of the relevant code was missing or changed compared to the default.

In this case, I used a different method, as described here:
http://www.templatemonster.com/help/ope ... -view.html

Looking for this came up empty:
if (view) {
display(view);
} else {
display('list');
}

In our theme, the 'else' was missing. By simply adding it as follows, it forced the default behavior back to grid.

else {
display('grid');
}

Removing the option from the top bar was basically the same as above, though I did need to sort out the div sections to make sure I commented out the correct portion.

So +1 for this working for that part.

Newbie

Posts

Joined
Wed Nov 12, 2014 4:15 pm
Who is online

Users browsing this forum: No registered users and 12 guests