Jump to content

Blocklayered + Datepicker


Recommended Posts

Hello,
 
For a development, I need to be able to sort my products by date.
I created a "Date" attribute, as well as a new type of overload attribute, which is "calendar date".
Thus, if you add a value to the date attribute, a datepicker field appears and saves a date to the database.
 
So far everything worked, I had to overload the Attribute class, the AdminAttributesGroupsController controller and the template form in that same controller (I could share the code if you need to realize the same development one day).
 
Now I wish I could sort it out. I overload the module blocklayered.
In front of "Attribute group: Date", I authorize the "Datepicker" filter style.

 

/theme/my_theme/modules/blocklayered/views/templates/admin/add_1.6.tpl

<div class="col-lg-6">
  <select name="layered_selection_ag_{(int)$attribute_group['id_attribute_group']}_filter_type">
    <option value="0">{l s='Checkbox' mod='blocklayered'}</option>
    <option value="1">{l s='Radio button' mod='blocklayered'}</option>
    <option value="2">{l s='Drop-down list' mod='blocklayered'}</option>
    {if $attribute_group['name'] == 'Date'}
    <option value="3">{l s='Datepicker' mod='blocklayered'}</option>
    {/if}
  </select>
</div>

/override/modules/blocklayered/blocklayered.php

if (!defined('_PS_VERSION_'))
	exit;

class BlockLayeredOverride extends BlockLayered
{
  public function hookHeader($params)
	{
		$this->context->controller->addJQueryUI('ui.datepicker');
    return parent::hookHeader($params);
	}

}

/theme/my_theme/modules/blocklayered/blocklayered.tpl

{elseif $filter.filter_type == 3}
  <input type="text" class="form-control datepicker" name="layered_{$filter.type_lite}_{$id_value}" id="layered_{$filter.type_lite}{if $id_value || $filter.type == 'quantity'}_{$id_value}{/if}"/>
  <script>
    $('.datepicker').datepicker();
  </script>
{else}

So much for the preliminaries. I now have an input field that opens a click calendar. Problem: I do not know what to override to have a function of type: according to the date chosen, in Ajax, load me all my products whose date is> = the date selected.   For info my date in BDD is in the format DATE (0000-00-00) Time is a characteristic and does not count in my search.   I have already tried to override the JS blocklayered_admin.js, blocklayered.js and blocklayered-footer.js, but it does not change anything. Someone would have any idea ? I did not find anything about the Ajax overload of this module, just a track could be of help to me.   Thank you !

post-839847-0-27088600-1502445205_thumb.png

post-839847-0-40824100-1502445211_thumb.png

post-839847-0-41729300-1502445215_thumb.png

post-839847-0-47417200-1502445220_thumb.png

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...