We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 46636
    • 6 Posts
    Hello,
    my day has been ruined by really unexpected problem with retrieving GET parameter value inside snippet. It is snippet I wrote and used several times with no problems even on the same version of MODX 2.2.9. Snippet needs URL GET param for pagination. It was really very simple:

    ...
    	if (isset($_GET['page']))
    		$page = intval(addslashes($_GET['page']));
    	else
    		$page = 1;
    ...
    


    But on new installation/copy of MODX the $_GET is empty. If I try to print it in the beginning of /index.php, it is OK. So MODX must delete it. Even if I create a new variable and copy $_GET to it MODX destroys it again. I even tried creating of named constants - but even those are deleted. Everything was checked in the beginning of /index.php file.

    Its even worse - even plugins are failing at this point, eg. setPlaceholders.

    I really dont know what to do. I tried upgrading to MODX 2.2.14 on a separated copy, upgrade was successfull but to no avail.

    Thank you very much for your time.

    This question has been answered by thiemel.jiri. See the first response.

      • 20413
      • 2,877 Posts
      Have you tried setting $_GET directly in a snippet or plugin?
      - different names and tested it unfiltered [ed. note: mrhaw last edited this post 12 years, 3 months ago.]
        @hawproductions | http://mrhaw.com/

        Infograph: MODX Advanced Install in 7 steps:
        http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

        Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
        http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
        • 28042 ☆ A M B ☆
        • 24,524 Posts
        Works fine for me. Both GET and REQUEST.
        <?php
        return $_GET['page'];
          Studying MODX in the desert - http://sottwell.com
          Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
          Join the Slack Community - http://modx.org
          • 3749
          • 24,544 Posts
          What is the full URL of the page with the snippet (with the query)?
            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
            • 46636
            • 6 Posts
            Of course i did! The part of code I posted if from the snippet. I mentioned the index.php experiment to make you sure, that it's not server issue. I worked fine for me also - but not now. I do not ask how to getGET parameter inside a snippet - the answer is always and everywhere the same - I'm doing it right. As I said I worked on several other MODX installations.
              • 46636
              • 6 Posts
              eg. www.something.com/?page=2
                • 28042 ☆ A M B ☆
                • 24,524 Posts
                You are using Friendly URLs, I presume.

                Perhaps something else is using that same key, clearing it when it's finished with it?
                  Studying MODX in the desert - http://sottwell.com
                  Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                  Join the Slack Community - http://modx.org
                  • 46636
                  • 6 Posts
                  1) I use FURLs, this has never been a problem.

                  2) No, that's not it - I tried randomly named GET params and the result is allways the same. Printing $_GET inside a snippet writes empty array. As I said at the beginning - it prints well before MODX initialized at the beginning of index.php. [ed. note: thiemel.jiri last edited this post 12 years, 3 months ago.]
                    • 28042 ☆ A M B ☆
                    • 24,524 Posts
                    Well, then, I don't know what to say. It doesn't do it on any of my MODX installations, nor have we heard anything from anybody else about a problem along these lines. I'm pretty much free today, so if you want to give me access I'll poke at it and see what I can find out.
                      Studying MODX in the desert - http://sottwell.com
                      Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                      Join the Slack Community - http://modx.org
                      • 3749
                      • 24,544 Posts
                      Have you tried $_REQUEST['page'] or using $_POST to send the param?

                      Have you modified the default .htaccess in a way that might be messing with the query string?
                        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