We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 3749
    • 24,544 Posts
    That sounds like a single search with some optional additional criteria. Sorry I can't be much help now -- pinched nerve in my shoulder -- can only type with one hand.

      Did I help you? Buy me a beer
      Get my Book: MODX:The Official Guide
      MODX info for everyone: http://bobsguides.com/modx.html
      My MODX Extras
      Bob's Guides is now hosted at A2 MODX Hosting
      • 8168
      • 1,118 Posts
      Quote from: BobRay at Oct 05, 2015, 03:35 AM
      That sounds like a single search with some optional additional criteria. Sorry I can't be much help now -- pinched nerve in my shoulder -- can only type with one hand.


      Ok thanks Bob - appreciate your thoughts thus far wink

      Anybody fancy helping here for a small fee? The PHP to achieve this is beyond me, but I need it working... Let me know.
        • 8168
        • 1,118 Posts
        Anyone any ideas on a solution for this? Happy to treat this as a mini project for a PHP wizard who can help!
          • 35756
          • 166 Posts
          Hi dubbs!

          Have you tried using the ClassExtender from Bob? As far as I remember getting it to work by using the "tutorial" on Bob's site hasn't been that hard if you follow it step by step. I made something somehow similar (users/members with about 15 custom fields, which had to be able to search in as well; btw I also had to use the login-package too. The registration form just needs some few standard fiels, then I created a resource "edit profile" in which the user is able to add data to the custom fields. When the user is logged in there is a search form with searches inbetween the standard and custom fields and the option to use multiple check-boxes that are "filtering" the search as well)
            • 8168
            • 1,118 Posts
            Quote from: profilneurotiker at Oct 06, 2015, 04:45 PM
            Hi dubbs!

            Have you tried using the ClassExtender from Bob? As far as I remember getting it to work by using the "tutorial" on Bob's site hasn't been that hard if you follow it step by step. I made something somehow similar (users/members with about 15 custom fields, which had to be able to search in as well; btw I also had to use the login-package too. The registration form just needs some few standard fiels, then I created a resource "edit profile" in which the user is able to add data to the custom fields. When the user is logged in there is a search form with searches inbetween the standard and custom fields and the option to use multiple check-boxes that are "filtering" the search as well)

            Hiya, I would rather not have to change everything to use ClassExtender to be honest - would be a rather massive job! Bob has also mentioned on this post he feels it is not necessary either. I have all the logic worked out - just need someone with the PHP knowledge to write the script... Anyone available to do this for a small fee?
            • discuss.answer
              • 8168
              • 1,118 Posts
              OK - got this working myself surprisingly! I ended up using a form with GET to post the values of the input/Selects to the URL, then pulling the values from the URL to the snippet - magically! it works!

              So... it is possible to search extended user fields without too much hassle! wink so long as you use pdoTools pdoUsers to fetch the data from the JSON string and then make your conditions in the &where element of the code call. [ed. note: dubbs last edited this post 8 years, 6 months ago.]
                • 3749
                • 24,544 Posts
                Right, the extended field actually contains a text string, which is what you deal with when you use a query to search it. You have to make sure the values are unique.

                If you get the extended fields in code with get('extended'), you get a PHP associative array (MODX converts it from JSON on the way out). And if you want to change it in code with set('extended', $myArray), you usually send an associative array (MODX converts it to JSON on the way in). I say 'usually' because I haven't looked at the code, but I suspect that if you send a JSON string, MODX will save that.
                  Did I help you? Buy me a beer
                  Get my Book: MODX:The Official Guide
                  MODX info for everyone: http://bobsguides.com/modx.html
                  My MODX Extras
                  Bob's Guides is now hosted at A2 MODX Hosting
                  • 8168
                  • 1,118 Posts
                  OK thanks Bob - I stand corrected... wink You know all of this way way better than I wink I am just happy it is working! The only thing missing, is that the freeform textbox, and the 3 selects are connected in OR sequence, so it returns results for any of the 4 search criteria matching a result - what would be supper nice, would be to have an option to make it work in AND sequence as well...

                  So currently, if you search in the freeform for "Chickens" and then in the 1st select menu for "Red", "Green" in the 2nd and "Purple" in the 3rd - you get members which contain any of the matches for Chickens, Red, Green or Purple - so each member might just match Red for example.

                  Could I do it so that, the results MUST match ALL the set criteria,

                  So if you search in the freeform for "Chickens" and then in the 1st select menu for "Red", "Green" in the 2nd and "Purple" in the 3rd - you get members which contain matches for Chickens, Red, Green and Purple - so far fewer members returned in the results as a more strict criteria is set.

                  Any ideas?

                  The code I am using for the OR function is:

                  &where=`[
                      {"modUserProfile.extended:LIKE":"%\"[[!Get_value01]]\"%"},
                      {"OR:modUserProfile.extended:LIKE":"%\"workregion\":\"[[!Get_Region]]\"%"},
                      {"OR:modUserProfile.extended:LIKE":"%\"schoolingphase\":\"[[!Get_SchoolingAge]\"%"},
                      {"OR:modUserProfile.extended:LIKE":"%\"subjectsoffered\":\"[[!Get_SubjectsTaught]]\"%"}
                  ]`
                  


                  With the snippet getting the value searched from the URL string following a <form> GET [ed. note: dubbs last edited this post 8 years, 6 months ago.]
                    • 3749
                    • 24,544 Posts
                    Try changing the ones you want to require from OR: to AND:.
                      Did I help you? Buy me a beer
                      Get my Book: MODX:The Official Guide
                      MODX info for everyone: http://bobsguides.com/modx.html
                      My MODX Extras
                      Bob's Guides is now hosted at A2 MODX Hosting
                      • 8168
                      • 1,118 Posts
                      Quote from: BobRay at Oct 09, 2015, 05:37 PM
                      Try changing the ones you want to require from OR: to AND:.

                      Thanks Bob, so to allow both OR and AND options... I guess I need two forms, one which uses ORs and one which uses ANDs? OR is there some clever way my brain is missing out on here...? [ed. note: dubbs last edited this post 8 years, 6 months ago.]