We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22840
    • 1,572 Posts
    Hi,

    I'm trying to get ADVSearch working but only with tick boxs but I can't seem to get it to output any results.

    I have the following:

    Call for searchform:
    [[!AdvSearchForm? &landing=`362` &tpl=`search-form`]]


    Search form template:

    <form id="[[+asId]]_advsea-form" class="advsea-form" action="[[~[[+landing]]]]" method="[[+method]]">
      <fieldset>
        <input type="hidden" name="id" value="[[+landing]]" />
        <input type="hidden" name="asId" value="[[+asId]]" />
    
       
    		<div class="col-1">
    			<h4>RANGES</h4>
    			<div class="block">
    				<div>
    					<input class="search-checkbox" type="checkbox" value="Supreme" name="Supreme">
    					<label class="search-title" for="Supreme">SUPREME</label>
    				</div>
    				<div>
    					<input class="search-checkbox" type="checkbox" value="Grande Collection" name="Grande Collection">
    					<label class="search-label" for="Grande Collection"> - Grande Collection</label>
    				</div>
    				<div>
    					<input class="search-checkbox" type="checkbox" value="Avenue Collection" name="Avenue Collection">
    					<label class="search-label" for="Avenue Collection"> - Avenue Collection</label>
    				</div>
    				<div>
    					<input class="search-checkbox" type="checkbox" value="Elegance Collection" name="Elegance Collection">
    					<label class="search-label" for="Elegance Collection"> - Elegance Collection</label>
    				</div>
    				<div>
    					<input class="search-checkbox" type="checkbox" value="Shine Collection" name="Shine Collection">
    					<label class="search-label" for="Shine Collection"> - Shine Collection</label>
    				</div>
    			</div><!-- closes block -->
    <div class="search-submit">
     [[+liveSearch:isnot=`1`:then=`<input type="submit" class="searchBtn" id="[[+asId]]_advsea-submit"  name="sub" value="[[%advsearch.search? &namespace=`advsearch` &topic=`default`]]" />`]]
    				</div>
    
    	</fieldset>
    </form>


    Then on my landing page I have:

    [[!AdvSearch? &withFields=`introtext` &withTVs=`collection,colour-change,design,dimensions,joint,range,refining,species,surface,warranty` &fields=`pagetitle,introtext,content` &showExtract=`2:introtext`]]


    As I say it's not outputting any results although there are some for the Grande Collection, there isn't even a no results found error message.

    What have I missed and thanks for any help.

    Cheers
      • 5811
      • 1,717 Posts
      If you want a form with checkboxes and then depending the checkboxes selected, found the results which match the "collection" tv with the selected values, use the following snippet call on the landing page:

      [[!AdvSearch? &queryHook=`myQHook` &withTVs=`collection` &fields=`pagetitle,introtext,content`]]


      And then create a snipppet named myQHook with the following content (not tested):

      <?php
      
      $collectionArray = array();
      if (isset($_REQUEST['Supreme'])) $collectionArray[] = 'Supreme';		// 
      if (isset($_REQUEST['Grande Collection'])) $collectionArray[] = 'Grande Collection';
      if (isset($_REQUEST['Avenue Collection'])) $collectionArray[] = 'Avenue Collection';
      if (isset($_REQUEST['Elegance Collection'])) $collectionArray[] = 'Elegance Collection';
      if (isset($_REQUEST['Shine Collection'])) $collectionArray[] = 'Shine Collection';
      
      $collectionList = implode(',',$collectionArray); // set up of the list of selected collection
      
      $andConditions = array(
          'tv.collection:IN' => $collectionList	// get only the results with "collection" tv value among the selected values
      );
      
      $qhDeclaration = array(
          'qhVersion' => '1.2',
      	'andConditions' => $andConditions
      );
      
      $hook->setQueryHook($qhDeclaration);
      return true;



      If you would like customize the search results and display some other tv values inside the results, add :

      &tpl=`searchResult` and &includeTVs=`colour-change,design,dimensions,joint,range,refining,species,surface,warranty`


      where searchResult is a customized version of the default "result" template.

      You can find more informations about queryHook with the queryhook documentation and demonstrations.