#1 2025-02-24 13:50:25

stefano
Member
2023-12-15
12

Piwigo Search: Load and use within Wordpress?

I want to include the Piwigo Search from my Piwigo Gallery directly on my Wordpress page.

I was thinking if I can include a text input form in which the search term is directed to the Piwigo Search

for example:
- "Term" written in the text input form in Wordpress
- Link to Piwigo index.php?/search/ and the search results for "Term"

Is this somehow possible? I didn´t found anything further yet.

Offline

 

#2 2025-03-04 13:21:30

Schneider-Fotografie
Extension maintainer
Berlin
2023-04-16
160

Re: Piwigo Search: Load and use within Wordpress?

Hello Stefano,
I have a code for you here that works very well. You insert it into Piwigo or Wordpress. The search form then searches either in Piwigo or in Wordpress.

Best regards, Olaf


Code:

<!DOCTYPE html>
<html lang="de">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Search form selection</title>
  <style>
    .search-container {
      display: flex;
      align-items: center;
      gap: 10px;
    }
    .search-container select,
    .search-container input,
    .search-container button {
      padding: 5px;
      font-size: 16px;
    }
  </style>
  <script>
    document.addEventListener("DOMContentLoaded", function() {
      function updateAction() {
        var searchType = document.getElementById("searchType").value;
        var wpForm = document.getElementById("searchForm");
        var piwigoForm = document.getElementById("quicksearch");

        if (searchType === "piwigo") {
          wpForm.style.display = "none";
          piwigoForm.style.display = "flex";
          piwigoForm.action = "qsearch.php";
        } else {
          piwigoForm.style.display = "none";
          wpForm.style.display = "flex";
          wpForm.action = window.location.origin + "/wordpress/";
        }
      }

      document.getElementById("searchType").addEventListener("change", updateAction);
      updateAction();
    });
  </script>
</head>
<body>

  <h1>Searchformular</h1>

  <!-- Searchform -->
  <div class="search-container">
    <select id="searchType">
      <option value="wordpress">WordPress</option>
      <option value="piwigo">Piwigo</option>
    </select>

    <!-- WordPress Searchform -->
    <form id="searchForm" method="get" class="search-container">
      <input type="text" name="s" placeholder="Search in WordPress...">
      <button type="submit">Search</button>
    </form>

    <!-- Piwigo Searchform -->
    <form class="search-container" role="search" action="qsearch.php" method="get" id="quicksearch" style="display: none;">
      <input type="text" name="q" id="qsearchInput" placeholder="Search in Piwigo...">
      <button type="submit">Search</button>
    </form>
  </div>

</body>
</html>

Last edited by Schneider-Fotografie (2025-03-05 09:09:26)


-Schneider-Photography- Gallery
----------------------------------
BYB | Block You Bots
„Stay human. I block the rest.“

Offline

 

#3 2025-03-05 09:40:44

stefano
Member
2023-12-15
12

Re: Piwigo Search: Load and use within Wordpress?

Schneider-Fotografie wrote:

Hello Stefano,
I have a code for you here that works very well. You insert it into Piwigo or Wordpress. The search form then searches either in Piwigo or in Wordpress.

Best regards, Olaf


Code:

<!DOCTYPE html>
<html lang="de">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Search form selection</title>
  <style>
    .search-container {
      display: flex;
      align-items: center;
      gap: 10px;
    }
    .search-container select,
    .search-container input,
    .search-container button {
      padding: 5px;
      font-size: 16px;
    }
  </style>
  <script>
    document.addEventListener("DOMContentLoaded", function() {
      function updateAction() {
        var searchType = document.getElementById("searchType").value;
        var wpForm = document.getElementById("searchForm");
        var piwigoForm = document.getElementById("quicksearch");

        if (searchType === "piwigo") {
          wpForm.style.display = "none";
          piwigoForm.style.display = "flex";
          piwigoForm.action = "qsearch.php";
        } else {
          piwigoForm.style.display = "none";
          wpForm.style.display = "flex";
          wpForm.action = window.location.origin + "/wordpress/";
        }
      }

      document.getElementById("searchType").addEventListener("change", updateAction);
      updateAction();
    });
  </script>
</head>
<body>

  <h1>Searchformular</h1>

  <!-- Searchform -->
  <div class="search-container">
    <select id="searchType">
      <option value="wordpress">WordPress</option>
      <option value="piwigo">Piwigo</option>
    </select>

    <!-- WordPress Searchform -->
    <form id="searchForm" method="get" class="search-container">
      <input type="text" name="s" placeholder="Search in WordPress...">
      <button type="submit">Search</button>
    </form>

    <!-- Piwigo Searchform -->
    <form class="search-container" role="search" action="qsearch.php" method="get" id="quicksearch" style="display: none;">
      <input type="text" name="q" id="qsearchInput" placeholder="Search in Piwigo...">
      <button type="submit">Search</button>
    </form>
  </div>

</body>
</html>

Works, great - thanks!

As an extra, would it somehow possible to load the tags and albums als suggestions from the RV autocomplete extension?

Last edited by stefano (2025-03-05 10:11:48)

Offline

 

Board footer

Powered by FluxBB