We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 20217
    • 5 Posts
    hi community,

    i need to use multiple search formulars with simple search in one page under revo. now i experienced a problem with the id selector of the form tag. It will be allways the same. so it will not run with js or css. i need to use js to submit the form. coz this is done outside of the formular.

    how can i get different id names in the chunk? i am thinking about something like

    <form id="sisea-form-[[+counter]]" ...
    


    is there an possibility to archive that?

    would be happy about some clue.

    greetings
      • 20217
      • 5 Posts
      just figured it out

      <form id="sisea-form-[[+searchIndex]]" ...
      


      and the call should be

      [[!SimpleSearchForm? &tpl=`SimpleSearchForm` &highlightTag=`strong` &landing=`13` &searchIndex=`search1`]]
      


      for the first fomular and

      [[!SimpleSearchForm? &tpl=`SimpleSearchForm` &highlightTag=`strong` &landing=`13` &searchIndex=`search2`]]
      


      for the second one. and so on.

      i put the call in a chunk and called that in the template. But i can call it directly in the template of course.

      thank you
        • 37619
        • 79 Posts
        Awesome. Thank you for that!
          Jean-Marc Buytaert (@jmbuytaert)

          MODX truly is the greatest thing that's ever happened to the Internet.
          • 37619
          • 79 Posts
          Actually, that didn't work. And here's why:

          The [[!simpleSearch]] call on the results page also needs &searchIndex=`whatever-the-search-index-is`, but this:
          [[!simpleSearch? &searchIndex=`[[+searchIndex]]`]] 
          did not work (I tried cached and uncached searchIndex).

          So I had to create a snippet that pulls the $_GET variable from the URL and put that snippet in the simpleSearch call.

          Here's what I did:

          FORM
          <form id="sisea-form-[[+searchIndex]]" ...


          simpleSearchForm Call 1
          [[!simpleSearchForm? ... &searchIndex=`search1`]]


          simpleSearchForm Call 2
          [[!simpleSearchForm? ... &searchIndex=`search2`]]


          simpleSearch Call (for search results)
          [[!simpleSearch? ... &searchIndex=`[[!getSearchIndex]]`]]


          getSearchIndex Snippet
          <?php
          	foreach($_GET as $k => $v){
          		if($k == "search1") return "search1";
          		if($k == "search2") return "search2";
          	}
          


          Hope that helps!
            Jean-Marc Buytaert (@jmbuytaert)

            MODX truly is the greatest thing that's ever happened to the Internet.
            • 45069
            • 22 Posts
            Good idea. thanks.