We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 30885
    • 18 Posts
    Need to use Google Custom Search on didyouknow.org. Stuck the google search code into a chunk and the google search results code in a separate chunk. Placed the search bar chunk at the top of the templates where I want the search bar to be and it looks right. Then created the search results page, with the google search results code chunk in it. But when trying to search, it only goes to the home page (current error page). Does one need a google search plugin or something?

    BTW, oddly, when entering a keyword that is same as a page name (eg. "nostradamus") it goes to that page without going to the search results page, although the page being displayed is not the friendly URL one, meaning it doesn’t have the comments and other widgets and chunks on it that it should have.
      • 1788
      • 1,103 Posts
        • 30885
        • 18 Posts
        Google Adsense custom search, I should have specified. As said, stuck the code into chunks but it’s not working, always returning to error page (currently home page) instead of the search results page. Search is one of the most used features on my site. Advice will be massively appreciated.
          • 5392
          • 2 Posts
          I can’t get this to work either. If I create a modx page, e.g., SearchResults.html, the page is retrievable when you manually enter that address. However, if Google tries to go to it, it just goes to the home page.
            • 9207 ☆ A M B ☆
            • 2,475 Posts
            Remove some variables from our scientific method:

            1. What happens when you put the Google code all on one page OUTSIDE of MODx? A normal static page? Does it work?
            2. What happens when you put the Google code in one MODx page (no use of Chunks)? Does it work?
              • 30885
              • 18 Posts
              Re Google Custom Search via Adsense:

              1. Yes, it works in normal html pages - I used it for years on the plain html version of the site.

              2. Tried it direct onto template and pages, didn’t work (modx removes some needed div codes). Put it in chunks and it still doesn’t work.

              See what happens when you search on didyouknow.org

              A solution to this problem would help a lot of modx webmasters because the CPM returns on ads on search results pages typically is higher than ads on other pages.
                • 9207 ☆ A M B ☆
                • 2,475 Posts
                Looking at didyouknow.org doesn’t really tell me anything because 1) I can’t see the back-end and 2) I don’t know what search results are SUPPOSED to be returned.

                Google search works... I’ve used it on a number of MODx sites, e.g. http://www.pocopico.com/

                When you had it working on the html version of the site, was it on the same host? Did you try it recently using the SAME google code?

                MODx does not remove div tags... the only time it alters things is when you’re logged into the manager and the QuickEdit plugin adds the floating edit widget.

                I didn’t understand what you were trying to say here:
                A solution to this problem would help a lot of modx webmasters because the CPM returns on ads on search results pages typically is higher than ads on other pages.

                Could you repeat that? I don’t think this is problem is that difficult to solve, so I’m confused as to what exactly is causing the difficulty. Can you post exactly what you’re putting into your chunks/templates/etc?
                  • 3749
                  • 24,544 Posts
                  I’m confused too. The Google search at didyouknow.org seems to be working in IE7 and FF 3.5.2.
                  Maybe you fixed it?
                    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
                    • 10449
                    • 956 Posts
                    That’s expected behaviour.

                    MODx and Google CSE use the same q parameter: Google for the search keyword, and MODx for the page-alias.

                    e.g.
                    http://www.didyouknow.org/searchresults.htm?cx=partner-pub-1391122886083255%3Ajn36kv-s5fw&cof=FORID%3A9&ie=ISO-8859-1&q=movies&x=0&y=0
                    will tell MODx to look for a page with the alias "movies" and display that. Hence, no Google search results.

                    The solution is to use an uppercase q for Google CSE: Q instead of q.
                    MODx + PHP are case-sensitive, but Google isn’t.

                    Case in point:
                    http://www.didyouknow.org/searchresults.htm?cx=partner-pub-1391122886083255%3Ajn36kv-s5fw&cof=FORID%3A9&ie=ISO-8859-1&Q=movies&x=0&y=0
                    (same URL as above, but with uppercase Q param)

                    Just change the search form accordingly:
                    <input type="text" name="Q" size="31" />


                      • 30885
                      • 18 Posts
                      If only I was half as clever as you guys! ganeshXL, you’re a genius - what an elegant, simple solution! Changed the "q" to uppercase "Q" and the search now works fine. Many thanks.

                      For the record, yes, I was using the same host and the same Google Custom Search as supplied by Adsense. Re the dropped div tags, I noticed that some codes, especially widget codes supplied by other sites, do get dropped but I guess it is the automated "code cleaning" issue in tinymce (even though I never use the supplied code cleaning button). So, not a modx issue, per se. Of course, sticking the code in a chunk overrides the tinymce issue.

                      With regards to the mentioned CPM returns, generally the click-through ratio on ads on a search results page is higher than the click-through ratio on ads on normal pages. In these times, every penny counts.

                      Thanks again for the replies.