We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22851
    • 805 Posts
    I am using friendly urls (with use friendly aliases = no). I want to display google search results on my page. I have given the search page an alias. The problem is that modx is trying to redirect my pages based on the google search query. I know that this issue has been brought up before. It would be great to hear from anyone that has found a workaround for it (which doesn’t involve hacking the modx core code.)

    Thank you,

    Paul
      YAMS: Yet Another Multilingual Solution for MODx
      YAMS Forums | Latest: YAMS 1.1.9 | YAMS Documentation
      Please consider donating if you appreciate the time and effort spent developing and supporting YAMS.
      • 22303 MODX Staff
      • 10,725 Posts
      Out of curiosity, why would you run it with friendly alias’ off?

      In any case, no there is not currently an easy workaround without hacking the core, because the friendly url mechanism relies on the same query string parameter, $_GET[’q’], as the search (unless you can change the query string google search uses somehow).

      In the 0.9.7 branch, these parameters have been made configurable, but it took some substantial refactoring.
        • 22851
        • 805 Posts
        Re: Use friendly aliases, ’off’

        I would like modx to use the prefix, and suffix specified on the configuration page together with the page id to form the alias... unless I override the alias by specifying one for the page: I know it’s just aesthetic, but I don’t want all my pages to have the same suffix. They are not all html. This is what I understood what would happen if I chose friendly aliases ’off’ from the explanation on the friendly urls configuration tab, but it’s not entirely clear. Have I got it right, because it doesn’t appear to work? Even with friendly aliases off, it always uses the ’prefix id suffix’ combination.

        Re: Google ads and $_GET[’q’].

        After making the post last night, I figured out a solution using bits and pieces I read in forums that lets me include google ads in a (XHTML) modx page. First I modify the GET parameter used by the google search box, changing the
        <input type="text" name="q" ... 

        for
        <input type="text" name="mdxq" ... 

        (Don’t worry, it’s changed back before the search is submitted.) I direct the search to the modx page I want the ads on. Since the google query string doesn’t contain q=, this goes to the correct modx page. Next, I take the google search results code and put it into an html document that is on the server, but not managed by modx.

        So, GoogleSearch.html
        <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
        <html lang="en" >
        <head>
        <title>Google Search Results</title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" >
        <style type="text/css">
              body { margin: 0; padding: 0; }
        </style>
        </head>
        <body>
        <!-- Google Search Result Snippet Begins -->
        <div id="googleSearchUnitIframe"></div>
        
        <script type="text/javascript">
           var googleSearchIframeName = 'googleSearchUnitIframe';
           var googleSearchFrameWidth = 500;
           var googleSearchFrameborder = 0 ;
           var googleSearchDomain = 'www.google.co.uk';
        </script>
        <script type="text/javascript"
                 src="http://www.google.com/afsonline/show_afs_search.js">
        </script>
        <!-- Google Search Result Snippet Ends -->
        </body>
        

        Next I include the ads in my modx results page document, by writing a little snippet which takes the query string sent to the modx page, changes the mdxq GET parameter back to a q, and includes the GoogleSearch.html file with the correct parameters using <object>:
        <?php
        echo '<object data=".../GoogleSearch.html' . '?' . str_replace('mdxq=','q=',$_SERVER['QUERY_STRING']) . '" type="text/html" width="..." height="..." ></object>';
        ?>
        

        Then the search results appear wherever I place the snippet. Hey presto; Google ads on a modx page with no modx code hacks, and can be done in a completely standard conforming way. I hope that’s useful to other people out there.

        Paul
          YAMS: Yet Another Multilingual Solution for MODx
          YAMS Forums | Latest: YAMS 1.1.9 | YAMS Documentation
          Please consider donating if you appreciate the time and effort spent developing and supporting YAMS.
          • 22303 MODX Staff
          • 10,725 Posts
          Quote from: PMS at Nov 24, 2007, 02:39 PM

          Re: Use friendly aliases, ’off’

          I would like modx to use the prefix, and suffix specified on the configuration page together with the page id to form the alias... unless I override the alias by specifying one for the page: I know it’s just aesthetic, but I don’t want all my pages to have the same suffix. They are not all html. This is what I understood what would happen if I chose friendly aliases ’off’ from the explanation on the friendly urls configuration tab, but it’s not entirely clear. Have I got it right, because it doesn’t appear to work? Even with friendly aliases off, it always uses the ’prefix id suffix’ combination.

          No, you aren’t quite understanding it. The prefix and suffix, if you supply values, are always used if friendly urls is on, but aliases supplied for a document will not be used unless the friendly aliases option is on. Currently, the only way to control the suffix by content type is per document, simply by including the extension (i.e. .html) as part of the alias for html types. Future releases will feature custom extensions by content type.
            • 22851
            • 805 Posts
            Thanks for the replies. I’m using friendly aliases ’on’ now with no prefix or suffix and ensuring that an alias is set for each page. That’s working fine. The ’Q’ tip is also neat. I’ll give it a try. Cheers,

            Paul
              YAMS: Yet Another Multilingual Solution for MODx
              YAMS Forums | Latest: YAMS 1.1.9 | YAMS Documentation
              Please consider donating if you appreciate the time and effort spent developing and supporting YAMS.
              • 2690
              • 148 Posts
              wow ... such a simple solution!

              Q - works fine

              Thank you!


              aleks
                MODx Revo 2.0.6-pl (Traditional) | Apache 2.2.3 | PHP 5.2.14 | MySQL 5.0.77 | MAC OS 10.6.5 | FF 3.6/Chrome 9.0.5