contao-themes-net / mate-isotope-bundle

Support repository for MATE Isotope Bundle
0 stars 1 forks source link

Search not working #6

Open fritzmg opened 1 year ago

fritzmg commented 1 year ago

The iso_filter_mate template currently has the following code:

<?php if ($this->hasSearch): ?>
  <div class="search">
    <div class="heading"><?php echo $this->keywordsLabel; ?></div>
    <form action="<?php echo $this->action; ?>#sidebar-content" method="get">
      <input type="hidden" name="isorc" value="<?php echo \Input::get('isorc'); ?>">
      <?php /*<label for="ctrl_keywords_<?php echo $this->id; ?>"><?php echo $this->keywordsLabel; ?></label>*/?>
      <input type="text" name="keywords" id="ctrl_keywords_<?php echo $this->id; ?>" class="text" value="<?php echo $this->keywords; ?>" placeholder="<?php echo $this->defaultSearchText; ?>">
      <input type="submit" class="submit" value="<?php echo $this->searchLabel; ?>">
    </form>
  </div>
<?php endif; ?>

However, there is no $this->action variable (anymore) - which results in the following HTML output:

<form action="#sidebar-content" method="get">
    …
</form>

This in turn causes the request to always to go to https://example.com/#sidebar-content, no matter where this filter is used.

To fix this, the action needs to be removed completely:

<?php if ($this->hasSearch): ?>
  <div class="search">
    <div class="heading"><?php echo $this->keywordsLabel; ?></div>
-   <form action="<?php echo $this->action; ?>#sidebar-content" method="get">
+   <form method="get">
      <input type="hidden" name="isorc" value="<?php echo \Input::get('isorc'); ?>">
      <?php /*<label for="ctrl_keywords_<?php echo $this->id; ?>"><?php echo $this->keywordsLabel; ?></label>*/?>
      <input type="text" name="keywords" id="ctrl_keywords_<?php echo $this->id; ?>" class="text" value="<?php echo $this->keywords; ?>" placeholder="<?php echo $this->defaultSearchText; ?>">
      <input type="submit" class="submit" value="<?php echo $this->searchLabel; ?>">
    </form>
  </div>
<?php endif; ?>

or use something like this:


<?php if ($this->hasSearch): ?>
  <div class="search">
    <div class="heading"><?php echo $this->keywordsLabel; ?></div>
-   <form action="<?php echo $this->action; ?>#sidebar-content" method="get">
+   <form action="<?= Contao\Environment::get('request') ?>#sidebar-content" method="get">
      <input type="hidden" name="isorc" value="<?php echo \Input::get('isorc'); ?>">
      <?php /*<label for="ctrl_keywords_<?php echo $this->id; ?>"><?php echo $this->keywordsLabel; ?></label>*/?>
      <input type="text" name="keywords" id="ctrl_keywords_<?php echo $this->id; ?>" class="text" value="<?php echo $this->keywords; ?>" placeholder="<?php echo $this->defaultSearchText; ?>">
      <input type="submit" class="submit" value="<?php echo $this->searchLabel; ?>">
    </form>
  </div>
<?php endif; ?>
Manfred-Gipp commented 4 months ago

I have the same Problem. Contao 4.13.43. Which template needs to be changed?

fritzmg commented 4 months ago

@Manfred-Gipp see the initial description