Jump to content

[Solved] Blocklayered Meta-Title and product-count result


Recommended Posts

I've been searching for an answer to my questions for the last 3 hours but I can't fix my problem. I really hope someone here is able to help me.

 

My site is not live yet but I activated it so you guys can (hopefully) help me.

 

URL: https://tassenop8.nl/index.php

Prestashop version: 1.6.0.9

Theme: default

Version Layered Navigation Block: 2.0.7

 

Problem 1: When I use the layered navigation, the page with the results displays the meta-title of the category shown at that moment. I've looked everywhere how to disable it (without just deleting the meta-title) but I realy can't find an answer.

 

Problem 2: When using the layered navigation, the number of results shown is displayed as (for example) "shows 1 - 2 of 2 5 items". 

The 5 in the end, is the number of items in the category in total, so without the layered navigation option. How can I make this display correct? It shoud be "shows 1 - of 2 items"

 

EDIT:

At the homepage, everything looks fine. When you choose one of the categories at the left, it still looks fine. But when you make a choice in the layered navigation, after choosing a category, the problem occures. 

I hope with this edit my problem is more clear :)

 

I've added printscreens of my issues. Many thanks in advance!

 

 

PS: I'm new to building websites so please be gentle ;)

post-885528-0-26377100-1423440334_thumb.jpg

post-885528-0-46361900-1423440335_thumb.jpg

Edited by Silvia - Tassen op 8 (see edit history)
Link to comment
Share on other sites

Well, it is possible that no-one is answering this question because it looks good to me.

If I go to your website, I realy see something like this: Toont 1 - 5 van de 5 items.

 

It doesn't show to me the way you described, did you disable your layered navigation?

Maybe enable it so we can see what is going on.

 

Thanks.

Link to comment
Share on other sites


/*

* 2007-2014 PrestaShop

*

* NOTICE OF LICENSE

*

* This source file is subject to the Academic Free License (AFL 3.0)

* that is bundled with this package in the file LICENSE.txt.

* It is also available through the world-wide-web at this URL:

* http://opensource.org/licenses/afl-3.0.php

* If you did not receive a copy of the license and are unable to

* obtain it through the world-wide-web, please send an email

* to [email protected] so we can send you a copy immediately.

*

* DISCLAIMER

*

* Do not edit or add to this file if you wish to upgrade PrestaShop to newer

* versions in the future. If you wish to customize PrestaShop for your

* needs please refer to http://www.prestashop.com for more information.

*

* @author PrestaShop SA <[email protected]>

* @copyright 2007-2014 PrestaShop SA

* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)

* International Registred Trademark & Property of PrestaShop SA

*/

 

var ajaxQueries = new Array();

var ajaxLoaderOn = 0;

var sliderList = new Array();

var slidersInit = false;

 

$(document).ready(function()

{

cancelFilter();

openCloseFilter();

 

// Click on color

$(document).on('click', '#layered_form input[type=button], #layered_form label.layered_color', function(e) {

if (!$('input[name='+$(this).attr('name')+'][type=hidden]').length)

$('<input />').attr('type', 'hidden').attr('name', $(this).attr('name')).val($(this).attr('rel')).appendTo('#layered_form');

else

$('input[name='+$(this).attr('name')+'][type=hidden]').remove();

reloadContent();

});

 

$(document).on('click', '#layered_form .select', function(e) {

reloadContent();

});

 

$(document).on('click', '#layered_form input[type=checkbox], #layered_form input[type=radio]', function(e) {

reloadContent();

});

 

// Changing content of an input text

$(document).on('keyup', '#layered_form input.layered_input_range', function(e)

{

if ($(this).attr('timeout_id'))

window.clearTimeout($(this).attr('timeout_id'));

 

// IE Hack, setTimeout do not acept the third parameter

var reference = this;

 

$(this).attr('timeout_id', window.setTimeout(function(it) {

if (!$(it).attr('id'))

it = reference;

 

var filter = $(it).attr('id').replace(/^layered_(.+)_range_.*$/, '$1');

 

var value_min = parseInt($('#layered_'+filter+'_range_min').val());

if (isNaN(value_min))

value_min = 0;

$('#layered_'+filter+'_range_min').val(value_min);

 

var value_max = parseInt($('#layered_'+filter+'_range_max').val());

if (isNaN(value_max))

value_max = 0;

$('#layered_'+filter+'_range_max').val(value_max);

 

if (value_max < value_min) {

$('#layered_'+filter+'_range_max').val($(it).val());

$('#layered_'+filter+'_range_min').val($(it).val());

}

reloadContent();

}, 500, this));

});

 

$(document).on('click', '#layered_block_left .radio', function(e)

{

var name = $(this).attr('name');

$.each($(this).parent().parent().find('input[type=button]'), function (it, item) {

if ($(item).hasClass('on') && $(item).attr('name') != name) {

$(item).click();

}

});

return true;

});

 

// Click on label

$('#layered_block_left label a').on({

click: function(e) {

e.preventDefault();

var disable = $(this).parent().parent().find('input').attr('disabled');

if (disable == ''

|| typeof(disable) == 'undefined'

|| disable == false)

{

$(this).parent().parent().find('input').click();

reloadContent();

}

}

});

 

layered_hidden_list = {};

$('.hide-action').on('click', function(e)

{

if (typeof(layered_hidden_list[$(this).parent().find('ul').attr('id')]) == 'undefined' || layered_hidden_list[$(this).parent().find('ul').attr('id')] == false)

{

layered_hidden_list[$(this).parent().find('ul').attr('id')] = true;

}

else

{

layered_hidden_list[$(this).parent().find('ul').attr('id')] = false;

}

hideFilterValueAction(this);

});

$('.hide-action').each(function() {

hideFilterValueAction(this);

});

 

$('.selectProductSort').unbind('change').bind('change', function(event) {

$('.selectProductSort').val($(this).val());

 

if($('#layered_form').length > 0)

reloadContent();

});

 

$(document).off('change').on('change', 'select[name=n]', function(e)

{

$('select[name=n]').val($(this).val());

reloadContent();

});

 

paginationButton(false);

initLayered();

});

 

function initFilters()

{

if (typeof filters !== 'undefined')

{

for (key in filters)

{

if (filters.hasOwnProperty(key))

var filter = filters[key];

 

if (typeof filter.slider !== 'undefined' && parseInt(filter.filter_type) == 0)

{

var filterRange = parseInt(filter.max)-parseInt(filter.min);

var step = filterRange / 100;

 

if (step > 1)

step = parseInt(step);

 

addSlider(filter.type,

{

range: true,

step: step,

min: parseInt(filter.min),

max: parseInt(filter.max),

values: [filter.values[0], filter.values[1]],

slide: function(event, ui) {

stopAjaxQuery();

 

if (parseInt($(event.target).data('format')) < 5)

{

from = formatCurrency(ui.values[0], parseInt($(event.target).data('format')),

$(event.target).data('unit'));

to = formatCurrency(ui.values[1], parseInt($(event.target).data('format')),

$(event.target).data('unit'));

}

else

{

from = ui.values[0] + $(event.target).data('unit');

to = ui.values[1] + $(event.target).data('unit');

}

 

$('#layered_' + $(event.target).data('type') + '_range').html(from + ' - ' + to);

},

stop: function () {

reloadContent();

}

}, filter.unit, parseInt(filter.format));

}

else if(typeof filter.slider !== 'undefined' && parseInt(filter.filter_type) == 1)

{

$('#layered_' + filter.type + '_range_min').attr('limitValue', filter.min);

$('#layered_' + filter.type + '_range_max').attr('limitValue', filter.max);

}

 

$('.layered_' + filter.type).show();

}

 

initUniform();

}

}

 

function initUniform()

{

$("#layered_form input[type='checkbox'], #layered_form input[type='radio'], select.form-control").uniform();

}

 

function hideFilterValueAction(it)

{

if (typeof(layered_hidden_list[$(it).parent().find('ul').attr('id')]) == 'undefined'

|| layered_hidden_list[$(it).parent().find('ul').attr('id')] == false)

{

$(it).parent().find('.hiddable').hide();

$(it).parent().find('.hide-action.less').hide();

$(it).parent().find('.hide-action.more').show();

}

else

{

$(it).parent().find('.hiddable').show();

$(it).parent().find('.hide-action.less').show();

$(it).parent().find('.hide-action.more').hide();

}

}

 

function addSlider(type, data, unit, format)

{

sliderList.push({

type: type,

data: data,

unit: unit,

format: format

});

}

 

function initSliders()

{

$(sliderList).each(function(i, slider){

$('#layered_'+slider['type']+'_slider').slider(slider['data']);

 

var from = '';

var to = '';

switch (slider['format'])

{

case 1:

case 2:

case 3:

case 4:

from = formatCurrency($('#layered_'+slider['type']+'_slider').slider('values', 0), slider['format'], slider['unit']);

to = formatCurrency($('#layered_'+slider['type']+'_slider').slider('values', 1), slider['format'], slider['unit']);

break;

case 5:

from = $('#layered_'+slider['type']+'_slider').slider('values', 0)+slider['unit']

to = $('#layered_'+slider['type']+'_slider').slider('values', 1)+slider['unit'];

break;

}

$('#layered_'+slider['type']+'_range').html(from+' - '+to);

});

}

 

function initLayered()

{

initFilters();

initSliders();

initLocationChange();

updateProductUrl();

if (window.location.href.split('#').length == 2 && window.location.href.split('#')[1] != '')

{

var params = window.location.href.split('#')[1];

reloadContent('&selected_filters='+params);

}

}

 

function paginationButton(nbProductsIn) {

if (typeof(current_friendly_url) === 'undefined')

current_friendly_url = '#';

 

$('div.pagination a').not(':hidden').each(function () {

if ($(this).attr('href').search('&p=') == -1) {

var page = 1;

}

else {

var page = $(this).attr('href').replace(/^.*&p=(\d+).*$/, '$1');

}

var location = window.location.href.replace(/#.*$/, '');

$(this).attr('href', location+current_friendly_url.replace(/\/page-(\d+)/, '')+'/page-'+page);

});

$('div.pagination li').not('.current, .disabled').each(function () {

var nbPage = 0;

if ($(this).hasClass('pagination_next'))

nbPage = parseInt($('div.pagination li.current').children().children().html())+ 1;

else if ($(this).hasClass('pagination_previous'))

nbPage = parseInt($('div.pagination li.current').children().children().html())- 1;

 

$(this).children().children().on('click', function(e)

{

e.preventDefault();

if (nbPage == 0)

p = parseInt($(this).html()) + parseInt(nbPage);

else

p = nbPage;

p = '&p='+ p;

reloadContent(p);

nbPage = 0;

});

});

 

 

//product count refresh

if(nbProductsIn!=false){

if(isNaN(nbProductsIn) == 0) {

// add variables

var productCountRow = $('.product-count').html();

var nbPage = parseInt($('div.pagination li.current').children().children().html());

var nb_products = nbProductsIn;

 

if ($('#nb_item option:selected').length == 0)

var nbPerPage = nb_products;

else

var nbPerPage = parseInt($('#nb_item option:selected').val());

 

isNaN(nbPage) ? nbPage = 1 : nbPage = nbPage;

nbPerPage*nbPage < nb_products ? productShowing = nbPerPage*nbPage :productShowing = (nbPerPage*nbPage-nb_products-nbPerPage*nbPage)*-1;

nbPage==1 ? productShowingStart=1 : productShowingStart=nbPerPage*nbPage-nbPerPage+1;

 

 

//insert values into a .product-count

productCountRow = $.trim(productCountRow);

productCountRow = productCountRow.split(' ');

productCountRow[1] = productShowingStart;

productCountRow[3] = productShowing;

productCountRow[5] = nb_products;

productCountRow = productCountRow.join(' ');

$('.product-count').html(productCountRow);

$('.product-count').show();

}

else {

$('.product-count').hide();

}

}

}

 

function cancelFilter()

{

$(document).on('click', '#enabled_filters a', function(e)

{

if ($(this).attr('rel').search(/_slider$/) > 0)

{

if ($('#'+$(this).attr('rel')).length)

{

$('#'+$(this).attr('rel')).slider('values' , 0, $('#'+$(this).attr('rel')).slider('option' , 'min' ));

$('#'+$(this).attr('rel')).slider('values' , 1, $('#'+$(this).attr('rel')).slider('option' , 'max' ));

$('#'+$(this).attr('rel')).slider('option', 'slide')(0,{values:[$('#'+$(this).attr('rel')).slider( 'option' , 'min' ), $('#'+$(this).attr('rel')).slider( 'option' , 'max' )]});

}

else if($('#'+$(this).attr('rel').replace(/_slider$/, '_range_min')).length)

{

$('#'+$(this).attr('rel').replace(/_slider$/, '_range_min')).val($('#'+$(this).attr('rel').replace(/_slider$/, '_range_min')).attr('limitValue'));

$('#'+$(this).attr('rel').replace(/_slider$/, '_range_max')).val($('#'+$(this).attr('rel').replace(/_slider$/, '_range_max')).attr('limitValue'));

}

}

else

{

if ($('option#'+$(this).attr('rel')).length)

{

$('#'+$(this).attr('rel')).parent().val('');

}

else

{

$('#'+$(this).attr('rel')).attr('checked', false);

$('.'+$(this).attr('rel')).attr('checked', false);

$('#layered_form input[type=hidden][name='+$(this).attr('rel')+']').remove();

}

}

reloadContent();

e.preventDefault();

});

}

 

function openCloseFilter()

{

$(document).on('click', '#layered_form span.layered_close a', function(e)

{

if ($(this).html() == '<')

{

$('#'+$(this).attr('rel')).show();

$(this).html('v');

$(this).parent().removeClass('closed');

}

else

{

$('#'+$(this).attr('rel')).hide();

$(this).html('<');

$(this).parent().addClass('closed');

}

 

e.preventDefault();

});

}

 

function stopAjaxQuery() {

if (typeof(ajaxQueries) == 'undefined')

ajaxQueries = new Array();

for(i = 0; i < ajaxQueries.length; i++)

ajaxQueries.abort();

ajaxQueries = new Array();

}

 

function reloadContent(params_plus)

{

stopAjaxQuery();

 

if (!ajaxLoaderOn)

{

$('.product_list').prepend($('#layered_ajax_loader').html());

$('.product_list').css('opacity', '0.7');

ajaxLoaderOn = 1;

}

 

data = $('#layered_form').serialize();

$('.layered_slider').each( function () {

var sliderStart = $(this).slider('values', 0);

var sliderStop = $(this).slider('values', 1);

if (typeof(sliderStart) == 'number' && typeof(sliderStop) == 'number')

data += '&'+$(this).attr('id')+'='+sliderStart+'_'+sliderStop;

});

 

$(['price', 'weight']).each(function(it, sliderType)

{

if ($('#layered_'+sliderType+'_range_min').length)

{

data += '&layered_'+sliderType+'_slider='+$('#layered_'+sliderType+'_range_min').val()+'_'+$('#layered_'+sliderType+'_range_max').val();

}

});

 

$('#layered_form .select option').each( function () {

if($(this).attr('id') && $(this).parent().val() == $(this).val())

{

data += '&'+$(this).attr('id') + '=' + $(this).val();

}

});

 

if ($('.selectProductSort').length && $('.selectProductSort').val())

{

if ($('.selectProductSort').val().search(/orderby=/) > 0)

{

// Old ordering working

var splitData = [

$('.selectProductSort').val().match(/orderby=(\w*)/)[1],

$('.selectProductSort').val().match(/orderway=(\w*)/)[1]

];

}

else

{

// New working for default theme 1.4 and theme 1.5

var splitData = $('.selectProductSort').val().split(':');

}

data += '&orderby='+splitData[0]+'&orderway='+splitData[1];

}

if ($('select[name=n]:first').length)

{

data += '&n=' + $('select[name=n]:first').val();

}

 

var slideUp = true;

if (params_plus == undefined)

{

params_plus = '';

slideUp = false;

}

 

// Get nb items per page

var n = '';

$('div.pagination select[name=n]').children().each(function(it, option) {

if (option.selected)

n = '&n=' + option.value;

});

 

ajaxQuery = $.ajax(

{

type: 'GET',

url: baseDir + 'modules/blocklayered/blocklayered-ajax.php',

data: data+params_plus+n,

dataType: 'json',

cache: false, // @todo see a way to use cache and to add a timestamps parameter to refresh cache each 10 minutes for example

success: function(result)

{

if (result.meta_description != '')

$('meta[name="description"]').attr('content', result.meta_description);

 

if (result.meta_keywords != '')

$('meta[name="keywords"]').attr('content', result.meta_keywords);

 

if (result.meta_title != '')

$('title').html(result.meta_title);

 

if (result.heading != '')

{

$('h1.page-heading .cat-name').html(result.heading);

$('span.category-name').html(result.heading);

}

 

$('#layered_block_left').replaceWith(utf8_decode(result.filtersBlock));

$('.category-product-count, .heading-counter').html(result.categoryCount);

 

if (result.productList)

$('.product_list').replaceWith(utf8_decode(result.productList));

else

$('.product_list').html('');

 

$('.product_list').css('opacity', '1');

if ($.browser.msie) // Fix bug with IE8 and aliasing

$('.product_list').css('filter', '');

 

if (result.pagination.search(/[^\s]/) >= 0) {

var pagination = $('<div/>').html(result.pagination)

var pagination_bottom = $('<div/>').html(result.pagination_bottom);

 

if ($('<div/>').html(pagination).find('#pagination').length)

{

$('#pagination').show();

$('#pagination').replaceWith(pagination.find('#pagination'));

}

else

{

$('#pagination').hide();

}

 

if ($('<div/>').html(pagination_bottom).find('#pagination_bottom').length)

{

$('#pagination_bottom').show();

$('#pagination_bottom').replaceWith(pagination_bottom.find('#pagination_bottom'));

}

else

{

$('#pagination_bottom').hide();

}

}

else

{

$('#pagination').hide();

$('#pagination_bottom').hide();

}

 

paginationButton(parseInt(result.categoryCount.replace(/[^0-9]/g,'')));

ajaxLoaderOn = 0;

 

// On submiting nb items form, relaod with the good nb of items

$('div.pagination form').on('submit', function(e)

{

e.preventDefault();

val = $('div.pagination select[name=n]').val();

$('div.pagination select[name=n]').children().each(function(it, option) {

if (option.value == val)

$(option).attr('selected', true);

else

$(option).removeAttr('selected');

});

// Reload products and pagination

reloadContent();

});

if (typeof(ajaxCart) != "undefined")

ajaxCart.overrideButtonsInThePage();

 

if (typeof(reloadProductComparison) == 'function')

reloadProductComparison();

 

filters = result.filters;

initFilters();

initSliders();

 

current_friendly_url = result.current_friendly_url;

 

// Currente page url

if (typeof(current_friendly_url) === 'undefined')

current_friendly_url = '#';

 

// Get all sliders value

$(['price', 'weight']).each(function(it, sliderType)

{

if ($('#layered_'+sliderType+'_slider').length)

{

// Check if slider is enable & if slider is used

if(typeof($('#layered_'+sliderType+'_slider').slider('values', 0)) != 'object')

{

if ($('#layered_'+sliderType+'_slider').slider('values', 0) != $('#layered_'+sliderType+'_slider').slider('option' , 'min')

|| $('#layered_'+sliderType+'_slider').slider('values', 1) != $('#layered_'+sliderType+'_slider').slider('option' , 'max'))

current_friendly_url += '/'+blocklayeredSliderName[sliderType]+'-'+$('#layered_'+sliderType+'_slider').slider('values', 0)+'-'+$('#layered_'+sliderType+'_slider').slider('values', 1)

}

}

else if ($('#layered_'+sliderType+'_range_min').length)

{

current_friendly_url += '/'+blocklayeredSliderName[sliderType]+'-'+$('#layered_'+sliderType+'_range_min').val()+'-'+$('#layered_'+sliderType+'_range_max').val();

}

});

 

if (current_friendly_url == '#')

current_friendly_url = '#/';

 

window.location.href = current_friendly_url;

lockLocationChecking = true;

 

if(slideUp)

$.scrollTo('.product_list', 400);

updateProductUrl();

 

$('.hide-action').each(function() {

hideFilterValueAction(this);

});

 

if (display instanceof Function) {

var view = $.totalStorage('display');

 

if (view && view != 'grid')

display(view);

}

}

});

ajaxQueries.push(ajaxQuery);

}

 

function initLocationChange(func, time)

{

if(!time) time = 500;

var current_friendly_url = getUrlParams();

setInterval(function()

{

if(getUrlParams() != current_friendly_url && !lockLocationChecking)

{

// Don't reload page if current_friendly_url and real url match

if (current_friendly_url.replace(/^#(\/)?/, '') == getUrlParams().replace(/^#(\/)?/, ''))

return;

 

lockLocationChecking = true;

reloadContent('&selected_filters='+getUrlParams().replace(/^#/, ''));

}

else {

lockLocationChecking = false;

current_friendly_url = getUrlParams();

}

}, time);

}

 

function getUrlParams()

{

if (typeof(current_friendly_url) === 'undefined')

current_friendly_url = '#';

 

var params = current_friendly_url;

if(window.location.href.split('#').length == 2 && window.location.href.split('#')[1] != '')

params = '#'+window.location.href.split('#')[1];

return params;

}

 

function updateProductUrl()

{

// Adding the filters to URL product

if (typeof(param_product_url) != 'undefined' && param_product_url != '' && param_product_url !='#') {

$.each($('ul.product_list li.ajax_block_product .product_img_link,'+

'ul.product_list li.ajax_block_product h5 a,'+

'ul.product_list li.ajax_block_product .product_desc a,'+

'ul.product_list li.ajax_block_product .lnk_view'), function() {

$(this).attr('href', $(this).attr('href') + param_product_url);

});

}

}

 

 

/**

* Copy of the php function utf8_decode()

*/

function utf8_decode (utfstr) {

var res = '';

for (var i = 0; i < utfstr.length;) {

var c = utfstr.charCodeAt(i);

 

if (c < 128)

{

res += String.fromCharCode(c);

i++;

}

else if((c > 191) && (c < 224))

{

var c1 = utfstr.charCodeAt(i+1);

res += String.fromCharCode(((c & 31) << 6) | (c1 & 63));

i += 2;

}

else

{

var c1 = utfstr.charCodeAt(i+1);

var c2 = utfstr.charCodeAt(i+2);

res += String.fromCharCode(((c & 15) << 12) | ((c1 & 63) << 6) | (c2 & 63));

i += 3;

}

}

return res;

}

 

Link to comment
Share on other sites

I'm having the same issue.

I'm using a dutch language.

 

Had this with both webserver Apache 2 and Nginx (php5-fpm).

The theme I'm using is leo's theme; one that is pretty nice but I have had some issues in the theme which makes me think it's either the theme or the Prestashop version (had it with 1.6.0.9 and 1.6.0.11)

At first glance all looks well but when you select a filter, deselect it and select another filter it doesn't display the results but it does display the summary.

post-870330-0-06268000-1424349441_thumb.png

 

I have been trying to change caching settings in order for this issue to be eliminated but no luck so far.

Link to comment
Share on other sites

I am realy sorry for the late response, but this seems to be coming from your translation done in your back-end.

Is there a possibility for you to take a screenshot of the translation done in your back-end and show it to us please?

Because you have to make sure if the translation in your language has correctly added %1$d, %2$d (and one time %3$d).

 

Also in this translation for some reason, you are not allowed to start with a numeric value or multiple words.

So make sure there is only one word in front of your numeric translation, for example:

[ %1$d - %2$d van %3$d items ]

Make sure you only use one word in front of %3$d.

 

Let me know if this fixes your problem.

Link to comment
Share on other sites

Hi Helldog,

 

Actually I think the translation somehow fails for this part.

Try and put a few words in between.

 

I'm not sure what takes care of this but it doesn't look like it's a proper string replace action.

 

Cheers,

 

Eric Oud Ammerveld

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...