Filters customization (assign new classess and JS)

  • Posts: 98
  • Thank you received: 2
10 years 9 months ago #141846

Hello.
So imagine I got a price filter. And i'm using Bootstrap 3. And I want to wrap it onto the popover like here:
getbootstrap.com/javascript/#popovers-examples (CTRL+F "popover on bottom")
Using JS or CSS. I'm kinda fluent in it, but I got no idea where to assign those needed classes for the filters?

In the source code I got something like this:

<div class="hikashop_filter_filter_13">
   <span class="price radiobutton">650$</span>
</div>

What I want to know, what should I edit to insert the bootstrap's stuff into the code:
<div class="hikashop_filter_filter_13 [b]data-toggle="popover" data-placement="bottom"[/b]>
   <span class="price radiobutton">650$</span>
</div>

or using <scrypt> for the JS

Could you please clarify it since I'm very weak in the php stuff and there's nothing similar to in in the documentation.

Please Log in or Create an account to join the conversation.

  • Posts: 2334
  • Thank you received: 403
10 years 9 months ago #141862

Hi there,

Indeed it's a bit tricky since the code generating filters is in the class. You can find this class in administrator/components/com_hikashop/classes it's named filter. There you should be able to retrieve the spans and div of the filters and add whatever you want.
You can also take a look at the view filter in Display>Views and add some stuff here.

For the JS, something like that should work:

<?php
$js="your JS";
$doc = JFactory::getDocument();
$doc->addScriptDeclaration( $js);
?>

You have to place it in the view.

Last edit: 10 years 9 months ago by Eliot.

Please Log in or Create an account to join the conversation.

  • Posts: 98
  • Thank you received: 2
10 years 9 months ago #142539

Eliot wrote: Hi there,

Indeed it's a bit tricky since the code generating filters is in the class. You can find this class in administrator/components/com_hikashop/classes it's named filter. There you should be able to retrieve the spans and div of the filters and add whatever you want.
You can also take a look at the view filter in Display>Views and add some stuff here.

For the JS, something like that should work:

<?php
$js="your JS";
$doc = JFactory::getDocument();
$doc->addScriptDeclaration( $js);
?>

You have to place it in the view.


Well. Let me come with an easier example. I wan't to place an icon of cart into your Hikashop Cart Module.
I go to Hikashop > Views > showcart view (of the required template, of course)
And I see that on the front-end the place, name of the class, where I want to assign the icon to named:
hikashop_cart
I make CTRL+F and try ti find this class in the showcart.php file, but there is no such a class, I do the same with every "cart" view of the template, and still, no class or id found.
hikashop_cart

Could you please write a guide or manual for how to do the stuff like that for its very hard to customize the site through CSS only without editing the HTML structure

Last edit: 10 years 9 months ago by Shulha.

Please Log in or Create an account to join the conversation.

  • Posts: 2334
  • Thank you received: 403
10 years 9 months ago #142614

Filters are a bit particular since they are generated by the class.
As the values may differ according to your configuration, it cannot simply be in a view or modified with CSS.
So the solutions I gave you are actually the only ones for your case.

I hope I didn't misunderstood what you want to do but if you still want to do the thing you posted first, looking at the class is the solution. As I said, filters are a particular case.

Last edit: 10 years 9 months ago by Eliot.

Please Log in or Create an account to join the conversation.

  • Posts: 98
  • Thank you received: 2
10 years 9 months ago #144246

Eliot wrote: Filters are a bit particular since they are generated by the class.
As the values may differ according to your configuration, it cannot simply be in a view or modified with CSS.
So the solutions I gave you are actually the only ones for your case.

I hope I didn't misunderstood what you want to do but if you still want to do the thing you posted first, looking at the class is the solution. As I said, filters are a particular case.


Well, I was trying very hard to find something in the
administrator/components/com_hikashop/classes
But it was no success.
But I really need to get this done so I'll provide the real example.

I want a filter to collapse on toggle.
Here is the working fiddle for this.
jsfiddle.net/Q4PUw/2/


I tried to look at the "views" of the filter in the Back-End and in the administrator folder "filter.php" via FTP, and as far as I could see, because of this code
<div class="hikashop_filter_main_div hikashop_filter_main_div_<?php $this->params->get('main_div_name'); ?>">
That is stored in the "filter" view of the Back-End, I can not assign a class or my jQuery code right to the place I want.

In the HTML markup here's something similar to what I want to see to get this jsFiddle working:
<div class="hikashop_filter_7">
	<span class="hikashop_filter_title"> Filter's title</span>
	<span class="expand_filter">Toggle to expand</span>

	<input type="some_stuff">Here comes the filter itself that expands on '.expand_filter' click</input>
</div>

I refuse to believe there's no way to make this kind of particular customization. There must be a way, easy or not, maybe depending on some patches from you, or writing some documentation.
Please, I really need to do something like this. Help me a bit.
What file should I be editing, how exactly, etc.
Thank you in advance.



Or, here's another workaround.
For example I have 6 filters
<div class="hikashop_filter_1"> Some stuff here</div>
<div class="hikashop_filter_2"> Some stuff here</div>
<div class="hikashop_filter_3"> Some stuff here</div>

<div class="hikashop_filter_4"> Some stuff here</div>
<div class="hikashop_filter_5"> Some stuff here</div>
<div class="hikashop_filter_6"> Some stuff here</div>

Filters from 1 to 3 are default, filters from 4-6 are optional.

I want filters 4-6 to be shown only when a user wants it.
So I do like that:
<div class="hikashop_filter_1"> Some stuff here</div>
<div class="hikashop_filter_2"> Some stuff here</div>
<div class="hikashop_filter_3"> Some stuff here</div>

<div class="toggle_to_expand">Show more params

     <div class="hikashop_filter_4"> Some stuff here</div>
     <div class="hikashop_filter_5"> Some stuff here</div>
     <div class="hikashop_filter_6"> Some stuff here</div>
</div>

And onClick the user gets displayed filters from 4 to 6.

God, if it has been the Bootstrap with the Smarty php engine, I would have done it myself.
But it's Joomla & Hikashop and I got no freaking idea how to customize and who else is supposed to help me since this software is yours :-)

Last edit: 10 years 9 months ago by Shulha.

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
10 years 9 months ago #144279

Hi,

In order to do that, there is no need to modify the filter class file.
Just edit the file "filter" of the view "product" via the menu Display>Views and change the code which echo the html of the filters in order to add your additional HTML div around the filters you want and then you can also add your toggle JS code in that file.
Here is the line which displays the filter div in that file:

echo '<div class="hikashop_filter_'.$filters[$count]->filter_namekey.'">'.$html[$count].'</div>';

Please Log in or Create an account to join the conversation.

  • Posts: 98
  • Thank you received: 2
10 years 9 months ago #144554

nicolas wrote: Hi,

In order to do that, there is no need to modify the filter class file.
Just edit the file "filter" of the view "product" via the menu Display>Views and change the code which echo the html of the filters in order to add your additional HTML div around the filters you want and then you can also add your toggle JS code in that file.
Here is the line which displays the filter div in that file:

echo '<div class="hikashop_filter_'.$filters[$count]->filter_namekey.'">'.$html[$count].'</div>';


Im afraid u didnt understand me right.
As far as I understand, if I add new class to that lane you provided, the class will be applied to all filters I have, from 1 to 13, but I only need this class to be applied on filters 7,8,9.
How to reach that?

Please Log in or Create an account to join the conversation.

  • Posts: 2334
  • Thank you received: 403
10 years 9 months ago #144602

Hi there,

As I told you it's gonna be tricky but here is how you should process.
Open the filter.php class and find the displayFilter function.
This function call a specific functions for each display (each type of filters).
What you can do is add some code here to display your additional div (admitting that you won't add any filter or change the order).
so here the code and what you could do:

function displayFilter($filter, $divName, &$parent, $datas=''){
		$html ='';
		if($filter->filter_type=='text' || $filter->filter_type=='singledropdown' || $filter->filter_type=='multipledropdown' || $filter->filter_type=='radio' || $filter->filter_type=='list' || $filter->filter_type=='checkbox' || $filter->filter_type=='cursor' || $filter->filter_type=='instockcheckbox'){
			$classType = 'hikashop'.ucfirst($filter->filter_type).'Class';
			$class = new $classType();
			$html = $class->display($filter, $divName, $parent, $datas);
			if($filter->filter_name=='thefirstfilteryouwannahide')
   			      $html = '<div class="yourdiv">'.$html;
			if($filter->filter_name=='thelasttfilteryouwannahide')
   			      $html .= '</div>';
		}else{
			JPluginHelper::importPlugin( 'hikashop' );
			$dispatcher = JDispatcher::getInstance();
			$dispatcher->trigger( 'onFilterDisplay', array( & $filter ,&$html, &$divName, &$parent, &$datas) );
		}
		return $html;
	}

it's a suggestion but it could definitely work :)

Please Log in or Create an account to join the conversation.

  • Posts: 98
  • Thank you received: 2
10 years 9 months ago #145233

Eliot wrote: Hi there,

As I told you it's gonna be tricky but here is how you should process.
Open the filter.php class and find the displayFilter function.
This function call a specific functions for each display (each type of filters).
What you can do is add some code here to display your additional div (admitting that you won't add any filter or change the order).
so here the code and what you could do:

function displayFilter($filter, $divName, &$parent, $datas=''){
		$html ='';
		if($filter->filter_type=='text' || $filter->filter_type=='singledropdown' || $filter->filter_type=='multipledropdown' || $filter->filter_type=='radio' || $filter->filter_type=='list' || $filter->filter_type=='checkbox' || $filter->filter_type=='cursor' || $filter->filter_type=='instockcheckbox'){
			$classType = 'hikashop'.ucfirst($filter->filter_type).'Class';
			$class = new $classType();
			$html = $class->display($filter, $divName, $parent, $datas);
			if($filter->filter_name=='thefirstfilteryouwannahide')
   			      $html = '<div class="yourdiv">'.$html;
			if($filter->filter_name=='thelasttfilteryouwannahide')
   			      $html .= '</div>';
		}else{
			JPluginHelper::importPlugin( 'hikashop' );
			$dispatcher = JDispatcher::getInstance();
			$dispatcher->trigger( 'onFilterDisplay', array( & $filter ,&$html, &$divName, &$parent, &$datas) );
		}
		return $html;
	}

it's a suggestion but it could definitely work :)


I am sorry but nothing seems to work here. No additional "<div>" is applied.

Here's the code:
function displayFilter($filter, $divName, &$parent, $datas=''){
		$html ='';
		if($filter->filter_type=='text' || $filter->filter_type=='singledropdown' || $filter->filter_type=='multipledropdown' || $filter->filter_type=='radio' || $filter->filter_type=='list' || $filter->filter_type=='checkbox' || $filter->filter_type=='cursor' || $filter->filter_type=='instockcheckbox'){
			$classType = 'hikashop'.ucfirst($filter->filter_type).'Class';
			$class = new $classType();
			$html = $class->display($filter, $divName, $parent, $datas);
			if($filter->filter_name=='hikashop_filter_filter_5')
   			      $html = '<div class="toggle-hide">'.$html;
			if($filter->filter_name=='hikashop_filter_filter_6')
   			      $html .= '</div>';
		}else{
			JPluginHelper::importPlugin( 'hikashop' );
			$dispatcher = JDispatcher::getInstance();
			$dispatcher->trigger( 'onFilterDisplay', array( & $filter ,&$html, &$divName, &$parent, &$datas) );
		}
		return $html;
	}

Maybe I shall provide you a link? Maybe I'm missing smth?
dstest.atservers.net/katalog

I want to reveal-on-toggle filters from 5 to 7
As far as I can see I added the names right but it still doesnt work.

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
10 years 9 months ago #145417

Hi,

You put hikashop_filter_filter_6, but your filter is not called hikashop_filter_filter_6, it is called Производитель as far as I can see.

Please Log in or Create an account to join the conversation.

Time to create page: 0.083 seconds
Powered by Kunena Forum