We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 17282
    • 283 Posts
    Ok .. now i have a search field on the site that searches the whole site .. and thats fine ..

    Now what i would like to do is this ...
    I have a folder called lyrics .. inside which goes well .. song lyrics .. what i want to do is put a search item on the foler front that searches ONLY the contents of that folder ... is this possible ?

    TIA

    Martyn
      Everytime you use Flash ... a puppy dies .....
      R.G Taylor
      • 22303 MODX Staff
      • 10,725 Posts
      The lyrics would have to be stored as MODx document content in order to make it available to our FlexSearchForm snippet. Otherwise, I believe you would have to incorporate a custom search snippet to search the physical content on the server. Just about any text-based search component would work if these files are text or HTML, so, yes, it is possible, but not without getting your feet wet at writing or integrating existing PHP search code...
        • 17282
        • 283 Posts
        They will be storeds as MODX doc content .. they will all be on seperate modx pages within the folder ... can i then set an instance of the search from to search only MODX docs within that folder?

        Thnx sorry if im not clear!
          Everytime you use Flash ... a puppy dies .....
          R.G Taylor
          • 22303 MODX Staff
          • 10,725 Posts
          Ok, I thought you meant a real filesystem directory with lyrics, not a MODx folder. In this case, yes, you can customize the FlexSearchForm snippet to only look at specific documents...in fact some new features in the next release will allow users to configure the search form to only look at a specific list of documents, be they all the parents of the current doc, or all the children of the current doc, or whatever custom criteria you might come up with. Look at lines 314 and 325 in the current FlexSearchForm snippet, and you’ll see code like this....
          $sql .= "$tbl.published = 1 AND $tbl.searchable=1 AND $tbl.deleted=0;";

          You could simply add the following code to search a single folder (assuming a document id of 5 for the folder) in MODx...
          $sql .= "$tbl.published = 1 AND $tbl.searchable=1 AND $tbl.deleted=0 AND $tbl.parent = 5;";
            • 6726
            • 7,075 Posts
            Nice tip Jason !

            I might just use that one also smiley
            Good to know FlexSearchForm will extend in the future !
              .: COO - Commerce Guys - Community Driven Innovation :.


              MODx est l'outil id
              • 22303 MODX Staff
              • 10,725 Posts
              Actually, the new features I’m talking about will also be in the MODx core, though I’m not sure if this is the final format. It will include two new API functions and a new array that maps parent documents to child documents, i.e.:
              $modx->documentMap;
              $modx->getParentIds($id);
              $modx->getChildIds($id);


              The new documentMap is a representation of the entire site map, persisted in the siteCache file. The two new API methods can then use that map to build an array of all the parent (getParentIds()) or all of the child document IDs (getChildIds()) from a specific document, without a single SQL query at runtime.

              I created this specifically for the requirement of being able to use the FlexSearchForm snippet to query a finite set of documents without having to do complex queries, so we already have this tested and working as a proof of concept.
                • 4095
                • 372 Posts
                Quote from: OpenGeek at Jan 16, 2006, 12:32 PM

                ...in fact some new features in the next release will allow users to configure the search form to only look at a specific list of documents, be they all the parents of the current doc, or all the children of the current doc, or whatever custom criteria you might come up with.

                Sounds awsome Jason, good to knwo its getting more functionality. I have a wish for it, however it may be outside the scope of FlexiSearch?

                Can it return results for PDF documents, ie find words in the PDF and return the PDF in the result list?
                  [img]http://www.emanz.ac.nz/assets/images/logo/emanz-icon_16x16.gif[/img] Emergency Management Academy of New Zealand [br] http://www.emanz.ac.nz[br][br]MODx Sandbox Login: sandbox Password: castle [br]
                  Admin Sandbox Login: sandbox Password: castle
                  • 18397
                  • 3,250 Posts
                  Thanks Jason! $modx->getChildIds($id); will be great! I can use this to replace Jared’s SQL version that I am currently using in NewsListing.
                    • 17282
                    • 283 Posts
                    you sir are a star .. ill try it in the morning smiley
                      Everytime you use Flash ... a puppy dies .....
                      R.G Taylor
                      • 17282
                      • 283 Posts
                      this worked an absolute treat !

                      many thanks smiley
                        Everytime you use Flash ... a puppy dies .....
                        R.G Taylor