We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 30023
    • 172 Posts
    Further to the above, I realise that you won’t be able to use the automatically generated extracts if done using the Ditto method. A similar alternative which would still enable you to use the extracts would be to first get Ditto to find all the non-containers, and feed that into the search snippet via &searchParents.

    Something like...

    &searchParents=[!Ditto? &where=`isFolder=0` &tpl=`idTpl` &lastTpl=`idLastTpl`!]


    with &idTpl being

    [+id+],


    and &idLastTpl being

    [+id+]


    Personally I’d be inclined to use the plugin method if you can write PHP.

    -- Tim.
      • 11139
      • 34 Posts
      Thanks Tim. I’ll just mark the containers unsearchable for now, I think, because what I’m trying to make is a simple annotated site (in Revo) for newcomers to MODx (like me) who won’t necessarily know PHP. The present version of the site is http://www.tgsketches.me.uk/cranford/ : I want to add a basic search page, and I’m making an annotation site to go in parallel to explain stuff.

      Thanks for your time.

      Thomas
        • 11139
        • 34 Posts
        Hi Tim,

        I have just download the current version (2.0 beta) for Revo, and I’m getting a verbose output, starting with:

        Search Terms array: array(1) { [0]=> string(8) "stamford" }
        Search Terms negative array: array(0) { }
        Neg query 1:
        Neg query 2:
        SELECT DISTINCT `tgsketch_cranf`.`site_content`.id, `tgsketch_cranf`.`site_content`.editedon FROM `tgsketch_cranf`.`site_content` LEFT JOIN
        .......

        How do I turn that off, please?

        Thomas
          • 30023
          • 172 Posts
          Sorry, I uploaded the file with debugging on. Either find the line "define(’DEBUG’, 1);" and change 1 to 0, or get the version I have just uploaded to my site.

          -- Tim.
            • 11139
            • 34 Posts
            Thought it might be something like that ;-)

            Thanks for quick response

            Thomas
              • 10169
              • 24 Posts
              Hi Tim,

              I’m trying to exclude pages from a private section of a Revo website unless the client is logged in. My first though was to do this:
              [[!If?
                 &subject=`[[!+modx.user.id]]`
                 &operator=`EQ`
                 &operand=``
                 &then=`[[!Search? &searchExcludeParents=`16`]]`  
                 &else=`[[!Search]]`
              ]]


              However, having multiple calls to your search snippet returns a blank page.

              What is the right way to accomplish this?

              Thanks!

              -Mike
                • 30023
                • 172 Posts
                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.
                  • 44234
                  • 219 Posts
                  Hi,

                  Love the snippet! I have set this up on a Revolution Site I’m working on and I have a question about the time it takes to return the results page.

                  Currently it takes 12.5096 seconds to return 49 items on the results page. This seems alot to me and am wondering what other peoples results are with this snippet? I’m concerned because once the site is finished, it will be searching over 1500 pages.

                  I have no problems with speed on any other page or snippet, front end or in the manager.

                  Thanks in advance for any advice!
                    Find me on Twitter, GitHub or Google+
                    • 30023
                    • 172 Posts
                    Hi,

                    I’ve just done some timings on an Evo site with 756 resources/documents in the site_content. Its a busy site and as such is on a dedicated server. To what extent this affects things I don’t know, but if a shared hosting company is packing them in enough for it to make a difference to a single page load time I suspect you need a different hosting company.

                    For comparison, the normal page load time on this site is usually 300-500ms, minimum 270ms, maximum 740ms.

                    Search results load time 1-3s in most cases (typically 20-40 results). Not super fast, admittedly, but not problematical in this case. One large result set (323 documents) took 5.25s, but this was the most extreme case.

                    These times include the network overheads, but I think its fair to say that the majority of the search page time is processing. Offhand I can’t be 100% sure how it scales, but I think the PHP execution time (not including SQL queries) in most cases will be linear according to the total finds as the number of documents gets very large (*).

                    I don’t know enough to comment on the MySQL execution time, but I’d would expect that to be less significant the the PHP. There is one query and I expect it could be optimised, but I doubt whether it would make much difference. I would have though that you’d have other problems with MODx and site size well before MySQL slowed down enough to be a problem.

                    12s seems rather long. How many documents is it currently searching? I suggest you try another server, or if you can edit PHP, edit the snippet code and run some tests.

                    I also suggest you try other search code for comparison (I only know of SimpleSearch, but I don’t know much about Revo). Much as I’d like to think my own code is faster, it may not be, especially as there is alot of non-obvious processing going on in the background to elimate false positives (**) and build the search extract. It would certainly be possible to write quicker search code if you were prepared to trade speed for a few occasional ’wrong’ results or if you just stuck to single byte character sets.

                    Note also that the comparison with other snippets isn’t entirely fair - how many other pages are there on your site that have to look at you entire site’s content?

                    -- Tim.

                    (*) actually linear according to total finds including false positives returned from MySQL. In most cases there will be zero false positives. Further explanation is probably a bit OTT for this thread, so see the code source.

                    (**) It’s a contrived and extreme example, but consider what would happen if a search snippet just did a crude search in some html content for the string ’div’.
                      • 44234
                      • 219 Posts
                      Thanks for your reply Tim. The timings you have mentioned are what I would expect, maby its not working so well with revo? Have run another test:

                      1 document found containing "robert"

                      0.0208 s - Query Time - Shows how long MODx took talking to the database
                      2 - Query Count -Shows how many database queries MODx made
                      0.5036 s - Parse Time - Shows how long MODx took to parse the page
                      0.5244 s - Total Time - Shows the total time taken to parse/ render the page
                      cache - Source - Shows the source of page, whether is database or cache.


                      68 documents found containing "the"

                      0.0085 s - Query Time - Shows how long MODx took talking to the database
                      2 - Query Count -Shows how many database queries MODx made
                      17.7421 s - Parse Time - Shows how long MODx took to parse the page
                      17.7506 s - Total Time - Shows the total time taken to parse/ render the page
                      cache - Source - Shows the source of page, whether is database or cache.

                      As you can see the times at the moment are far to long to make this viable. Can you think of anything that may be causing this? So strange considering I have had no problems.

                      Thanks
                        Find me on Twitter, GitHub or Google+