Skip to content
Grav 2.0 is officially stable. Read the announcement →
Archive

New plugin - can't get $_GET parameters

Started by Muut Archive 10 years ago · 1 replies · 373 views
10 years ago

Hello,
I've just created a new plugin, following the tutorial with the command bin/plugin devtools new-plugin. My goal is to read the GET parameters given with the URL and the output the result on the page.
Example: When I type www.example.com/testplugin?name=Bob&[email protected] in my browser, I want to read the values. Normally I can do that with $_GET['name'] and $_GET['email']. But the $_GET variable only has one value: $_GET[_url].
My plugin subscribes to the onPageContentRaw main event after checking the route, as shown in the tutorial. I simply changed one line to see if the values are present:

PHP
$e['page']->setRawContent("Dump of _GET: ".print_r($_GET, true) . "

" . $content);

Can anybody help me to understand, what I'm doing wrong? I thougt is, that $_GET and $_POST are global in every PHP script.

Thank you very much.
Robgnu

10 years ago

you may have a scope problem. Try to put this line before your dump:

TXT

global $_GET;
---

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1362 9 years ago
Archive · by Muut Archive, 9 years ago
2 939 9 years ago
Archive · by Muut Archive, 9 years ago
2 4069 9 years ago
Archive · by Muut Archive, 9 years ago
1 2959 9 years ago
Archive · by Muut Archive, 9 years ago
3 1124 9 years ago