Answer the question
In order to leave comments, you need to log in
OpenCart search not working?
Good afternoon, I’m studying OpenCart 2 and I can’t understand why the search doesn’t work, I seem to be doing everything right, but it doesn’t work, I wrote
<?=$search?>
in the header.tpl file
and created the search.ptl file,
here is the code
<div class="nav navbar-nav navbar-right">
<form class="navbar-form navbar-left" role="search" method="get" action="">
<div class="input-group">
<input type="text" class="form-control" value="<?= $search; ?>" placeholder="<?=$text_search; ?>">
<span class="input-group-btn">
<button type="submit" class="btn btn-default" name="go"><i class="glyphicon glyphicon-search"></i></button>
</span>
</div>
</form>
</div>
Answer the question
In order to leave comments, you need to log in
Here is the script that is responsible for the standard search opencart /catalog/view/javascript/common.js
...
$('#search input[name=\'search\']').parent().find('button').on('click', function() {
var url = $('base' .attr('href') + 'index.php?route=product/search';
var value = $('header #search input[name=\'search\']').val();
if (value ) { url += '&search=' + encodeURIComponent(value); }
location = url;
});
Those. you either need to add form id="search" or change the selector in common.js
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question