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

    I would like to put a filter on ajaxsearch by tv. I found ajaxsearch 1.9.0 beta and the &filter option is exactly what i need laugh When I put the &filter in the snippet call I don’t have any problems.

    However, I want them to be user editable. So I created a form that when the submit button is clicked checks which checkboxes are checked and generates the correct string to input in filter. I put them back in a hidden field in the form that is called filter.

    Only bad thing is that the filter value isn’t accepted by ajaxsearch.

    here is my form code:

    <form [+as.formId+] action="[+as.formAction+]" method="post">
        <input type="hidden" name="advSearch" value="[+as.advSearch+]" />
    
        Klimaat : <input type="checkbox" name="productgroepklimaat" value = "klimaat" />
        Douche automatisering: <input type="checkbox" name="productgroepdouche" value="douche automatisering" />
        Naregelingen: <input type="checkbox" name="productgroepnaregelingen" value="naregelingen" />
        Toegang <input type="checkbox" name="productgroeptoegang" value="toegang" />
        Energie: <input type="checkbox" name="productgroepenergie" value="energie" />
        Verlichting: <input type="checkbox" name= "productgroepverlichting" value="verlichting" />
        <br>
        FAQ: <input type="checkbox" name="documentsoortfaq" value="FAQ" />
        Bulletin: <input type="checkbox" name="documentsoortbulletin" value="Bulletin" />
        Manual: <input type="checkbox" name="documentsoortmanual" value="Manual" />
        Engineering Note: <input type="checkbox" name="documentsoortengineeringnote" value="Engineering note" />
        Training doc: <input type="checkbox" name="documentsoorttrainingdoc" value="Training doc" />
        <input type="hidden" name="filter" value="" />	
        <br>
        <input id="ajaxSearch_input" class="cleardefault" type="text" name="search" value="[+as.inputValue+]"[+as.inputOptions+] />
        <input type="submit" name="submit" value = "submit" onclick="convertfilter(this.form)"/>
    


    The problem lies in the line <input type="hidden" name="filter" value="" />. When I make this field visible, I see the correct text appearing, so its the name that isnt accepted by ajaxsearch. I also tried name="[+as.filter+]", but that placeholder is empty.

    Anyone knows what the correct name is to parse the filter trough an input form?

    Thanks in advance,

      • 5811
      • 1,717 Posts
      Jurrian, &filter is not the good way to filter the results. The main raison, is that the &filter parameter only filter the results provided by the search sql query. So, If the query doesn’t fit your need, you couldn’t filter anything.

      Look at this post, I am sure that you will be interested grin
      I will set the same demos with the ajax mode in the following days.

      And apologies, but the ajaxSearch 1.9.0 beta and even the 1.9.0 RC are already deprecated. I will post an RC2 before the end of the week.
        • 15076
        • 43 Posts
        Coroico, could you explain me why &filter isn’t the correct way? Because when I use the following call, it works exactly as I want:

        [!AjaxSearch &ajaxSearch=`0` &filter=`documentcategorie, FAQ, 7` &tplInput=`asinputtpl` !]

        My javascript generates the TVname, TVvalue, 7 part, and adds a | when multiple filters are selected. So I expected that if I can parse them trough with an input form, I am where I want to be:)

        Thanks for your link to the topic with new examples, posted some questions there also rolleyes

        Thanks,

          • 5811
          • 1,717 Posts
          could you explain me why &filter isn’t the correct way?
          because you do a filter AFTER the mysql search. Which is not performant.
          1/ You do a search and you got all the results that match the search term you want (what ever your filter parameters) and then you remove some unwanted documents by using &filter.
          2/ By using &tvPhx, you add, by PHP, for each document found, the content of all the TVs. If you have few documents, it could be ok, but with lot of documents, it will be slow.
          3/ Then, you do a filter with PHP (array_filter)

          So rather to use PHP (which is not very fast), the better way is to ask directly to MYSQL the appropriate sql order (columns and where clause)
            • 15076
            • 43 Posts
            I see what you mean. Next question that gets in my head is how to tell mysql what the sqlfilter will be.
            The only idea I have is to use &documents. I will create a snippet that returns a comma seperates list with documents that are marked with the correct tvvalue. Then I will parse this to ajaxsearcg. Looking at the cheatsheet the &documents is used with the mysql search right? So that would be a much quicker option then using &filter:)

            Thanks