T
T
Temur Begiev2015-04-04 19:18:40
opencart
Temur Begiev, 2015-04-04 19:18:40

How to implement search in Opencart?

Started learning Opencart. I'm making a template from scratch. I can't figure out how to search.
In the header.tpl, the place I needed indicated
<?php echo search ?>
the output is:

<div id="search" class="input-group">
  <input type="text" name="search" value="" placeholder="Поиск" class="form-control input-lg">
  <span class="input-group-btn">
    <button type="button" class="btn btn-default btn-lg"><i class="fa fa-search"></i></button>
  </span>
</div>

Nothing happens when pressed. What to do?
ps Are there any books or guides where you can read about designing a template from scratch?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey, 2015-04-04
@temurbegiev

You need to add a script:

$('.button-search').bind('click', function() {
    url = $('base').attr('href') + 'index.php?route=product/search';
    var search = $('input[name=\'search\']').attr('value');
    if (search) {
      url += '&search=' + encodeURIComponent(search);
    }
    location = url;
  });
$('#header input[name=\'search\']').bind('keydown', function(e) {
    if (e.keyCode == 13) {
      url = $('base').attr('href') + 'index.php?route=product/search';
      var search = $('input[name=\'search\']').attr('value');
      if (search) {
        url += '&search=' + encodeURIComponent(search);
      }
      location = url;
    }
  });

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question