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

    I think I edited my last post as you were writing your last one, so refer back to that again, particularly as regards not having problems elsewhere.

    Is this on a local machine, a shared host, or a dedicated server? If a shared host, try it on a local machine.

    -- Tim.
      • 44234
      • 219 Posts
      Yeah sorry Tim, just seen your edits!

      Its on a shared server with about 100 pages in total. Guess I will have to do some further testing in different enviroments. Didn’t mean to come across as critising your work, as I said I think its great, just a bit stumped with this prob as I am not very good with PHP!

      Thanks for your help and will post back if I manage to work it out
        Find me on Twitter, GitHub or Google+
        • 30023
        • 172 Posts

        Based on my own experience of implementing this code, I wouldn’t expect a site of 100 pages to have speed problems on any host. If you make any progress I’d be interested in anything you find out.

        -- Tim.
          • 10169
          • 24 Posts
          Quote from: TimGS at Mar 05, 2011, 08:17 PM

          Hi Mike,

          I don’t use Revo now (I had a brief flirtation only). The conditional ’If’ tag syntax is quite unfamiliar to me I’m afraid. As such, the only code I can really comment on is the search code itself. However my first question is whether [[!Search]], with or without the exclude parents parameter works on its own i.e. reduce your code as posted to [[!Search]] to see if the fault is really with the search code or with the conditional.

          I would point out a couple of things, which may or may not be helpful, but I’ll say them anyway:

          • Logic in presentation i.e. conditionals in templates in a general (not just MODx) sense is something to use with caution - do a quick google as alot has been said on this elsewhere.
          • The Search snippet is intended only to search the documents the user has access to anyway i.e. set access permissions on the documents in question so that only those users can see them, and all should be fine. This is well tested on Evo. Offhand, I can’t however be sure it works on Revo. If this could solve the issue anyway and you try it, please let me know what the outcome is, if only so I can advise others appropriately. Edit: Looking at the snippet source, I would expect it to work in Revo.

          --Tim.


          Thanks for your response, Tim! I was unaware that the snippet would automatically exclude results based on the user’s permissions, so it looks like I’m covered. grin -Mike
            • 10169
            • 24 Posts
            Quote from: TimGS at Mar 05, 2011, 08:17 PM

            Hi Mike,

            <snip>

            I would point out a couple of things, which may or may not be helpful, but I’ll say them anyway:

            • Logic in presentation i.e. conditionals in templates in a general (not just MODx) sense is something to use with caution - do a quick google as alot has been said on this elsewhere.
            • The Search snippet is intended only to search the documents the user has access to anyway i.e. set access permissions on the documents in question so that only those users can see them, and all should be fine. This is well tested on Evo. Offhand, I can’t however be sure it works on Revo. If this could solve the issue anyway and you try it, please let me know what the outcome is, if only so I can advise others appropriately. Edit: Looking at the snippet source, I would expect it to work in Revo.

            --Tim.


            Hey Tim,

            If I search for a term that exists only on a page I don’t have permission to access and nowhere else, a blank page is returned instead of the results page with "no results found." Otherwise, it works as expected in Revo. An easy fix, maybe?

            -Mike
              • 30023
              • 172 Posts
              Quote from: fretless at Mar 10, 2011, 10:20 PM

              Quote from: TimGS at Mar 05, 2011, 08:17 PM

              Hi Mike,

              <snip>

              I would point out a couple of things, which may or may not be helpful, but I’ll say them anyway:

              • Logic in presentation i.e. conditionals in templates in a general (not just MODx) sense is something to use with caution - do a quick google as alot has been said on this elsewhere.
              • The Search snippet is intended only to search the documents the user has access to anyway i.e. set access permissions on the documents in question so that only those users can see them, and all should be fine. This is well tested on Evo. Offhand, I can’t however be sure it works on Revo. If this could solve the issue anyway and you try it, please let me know what the outcome is, if only so I can advise others appropriately. Edit: Looking at the snippet source, I would expect it to work in Revo.

              --Tim.


              Hey Tim,

              If I search for a term that exists only on a page I don’t have permission to access and nowhere else, a blank page is returned instead of the results page with "no results found." Otherwise, it works as expected in Revo. An easy fix, maybe?

              -Mike

              Puzzling, as it works fine in Evo.

              If you search for terms that are included in both public and private areas, but are not logged in and hence do not have access to the private pages, what happens?

              If you search for terms that are included nowhere at all what happens?

              What I am after is whether it is just no finds that is a problem, or whether there is a problem searching private pages that are currently inaccessible to the user.

              Look for the line define(’DEBUG’, 0); and change 0 to 1. Post the output.

              -- Tim.
                • 10169
                • 24 Posts
                Quote from: TimGS at Mar 10, 2011, 11:17 PM

                Puzzling, as it works fine in Evo.

                If you search for terms that are included in both public and private areas, but are not logged in and hence do not have access to the private pages, what happens?

                If you search for terms that are included nowhere at all what happens?

                What I am after is whether it is just no finds that is a problem, or whether there is a problem searching private pages that are currently inaccessible to the user.

                Look for the line define(’DEBUG’, 0); and change 0 to 1. Post the output.

                -- Tim.

                Hi, Tim.

                With DEBUG on, if I search for a term that exists in both public and private pages while not logged in, it returns only the public results...
                Search Terms array: array(1) { [0]=> string(10) "pubprivtest" } 
                Search Terms negative array: array(0) { } 
                Neg query 1: 
                Neg query 2: 
                SELECT id, editedon FROM `modx`.`modx_site_content` WHERE published = 1 AND searchable = 1 AND deleted=0 AND (((`modx`.`modx_site_content`.pagetitle LIKE '%pubprivtest%') OR (`modx`.`modx_site_content`.longtitle LIKE '%pubprivtest%') OR (`modx`.`modx_site_content`.introtext LIKE '%pubprivtest%') OR (`modx`.`modx_site_content`.content LIKE '%pubprivtest%')))
                First Pass: array(1) { [14]=> array(2) { ["count"]=> int(1) ["date"]=> string(10) "1296837339" } } 
                

                Doc ID 14 contains the term "pubprivtest", but so does doc ID 32, which is not listed. Correction... the term exists in a TV on doc 32. If I move the term to the content field, the private page result is also listed, and the page breaks as noted below for the private only search.

                If I search for a term that exists nowhere on the site, I get a normal "No Results Found" response.

                If I search for a term that only exists on a private page while not logged in, I get a blank (untemplated) page with this:
                Search Terms array: array(1) { [0]=> string(8) "privatetest" } 
                Search Terms negative array: array(0) { } 
                Neg query 1: 
                Neg query 2: 
                SELECT id, editedon FROM `modx`.`modx_site_content` WHERE published = 1 AND searchable = 1 AND deleted=0 AND (((`modx`.`modx_site_content`.pagetitle LIKE '%privatetest%') OR (`modx`.`modx_site_content`.longtitle LIKE '%privatetest%') OR (`modx`.`modx_site_content`.introtext LIKE '%privatetest%') OR (`modx`.`modx_site_content`.content LIKE '%privatetest%')))
                First Pass: array(2) { [20]=> array(2) { ["count"]=> int(1) ["date"]=> string(10) "1299685039" } [21]=> array(2) { ["count"]=> int(1) ["date"]=> string(10) "1299790412" } } 
                

                It clearly finds private docs 20 and 21, neither of which I have permission to view.

                Strange, eh? If the search term is in a TV on a private page, it is ignored unless I am logged-in. But, if the term is in a normal document field like pagetitle or content, it shows up whether I have permissions or not and fouls things up.

                -Mike


                  • 30023
                  • 172 Posts
                  The output is as expected. The first pass finds all documents with those terms. The same code that then builds the search extracts also knocks out any false positives such as these.

                  I’ll have a look later on.

                  -- Tim.


                    • 10169
                    • 24 Posts
                    I just edited my previous post with some new findings. See above.
                      • 30023
                      • 172 Posts
                      If the search term is in a TV on a private page, it is ignored unless I am logged-in. But, if the term is in a normal document field like pagetitle or content, it shows up whether I have permissions or not and fouls things up.

                      Thats helpful information, but I need some clarification.

                      If the search term is in a TV on a private page, it is ignored unless I am logged-in.

                      By this do you mean it works fine, or it just gives you a blank page?

                      if the term is in a normal document field like pagetitle or content, it shows up whether I have permissions or not and fouls things up.

                      Is this what produces the blank page?

                      -- Tim.