Jump to content

[SOLVED]Modify BlockLayered remove weight decimals


sickshot
 Share

Recommended Posts

hi i need to customize layered navigation filter, so when you move slider it shows weight rounded. in other words i want to remove decimals form weight slider.

 

1kg, 2 kg . 3 kg and so on and not like 1.45kg or something like this.

 

any ideas how to do this?

Edited by sickshot (see edit history)

Share this post


Link to post
Share on other sites

Somewhere near line 156 in blocklayered.tpl ( PS v1.5.2 ) is the javascript where the size of the steps is determined for all the layered_slider filter types:

 var step = filterRange / 100;

But any change there will affect all sliders, including price. You'll need to figure out / flag the weight slider from the other sliders and then have the template serve your customized javascript based on that.

 

I haven't played with the Layered Nav. very much, but I hope this points you in the right direction...

 

Good Luck,

Edited by Terragg (see edit history)

Share this post


Link to post
Share on other sites

You might consider doing some 'adjustment math' to the filterRange variable in the lines before the place where steps is defined. That way you can be sure to get integer values as steps for the slider.

Share this post


Link to post
Share on other sites

In general, you can add this piece of code to limit the decimals

 

{printf("%.0f",$myVariableWithDecimals)}

 

Didn't check where to put it in the blocklayered, but if you found the variable(s) already, try to wrap it/them with this code

 

Hope this helps,

Pascal

  • Like 1

Share this post


Link to post
Share on other sites

  • 2 weeks later...

Finality found a solution:

i have edited /modules/blocklayered/blocklayered.php

$weight_array = array(
  'type_lite' => 'weight',
  'type' => 'weight',
  'id_key' => 0,
  'name' => $this->l('Weight'),
  'slider' => true,
  'max' => '0',
  'min' => null,
  'values' => array ('1' => 0),

  'format' => 5, // Ex: xxxxx kg
  'filter_show_limit' => $filter['filter_show_limit'],
  'filter_type' => $filter['filter_type']
 );

 

and changed

'format' => 5, // Ex: xxxxx kg

to

'format' => 1, // Ex: xxxxx kg

thats all :)

  • Like 1

Share this post


Link to post
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
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More