Determine the current view
Hello Vanilla community!
I'm trying to develop a plugin to display content in the side menu of the site.
I wish can determine the current view for display different content (for example, main page 'discussions', a category page, a single post, a search, etc ...)
I tried to get information from the querystring with $_GET['p'] but do not return anything, I try use '$ Sender-> ControllerName' but always is 'discussionscontroler' and does not give me more information.
¿Any ideas?
Thanks in advance. I hope can help you in the future!
A greeting.
Best Answer
-
peregrine MVP
see
http://vanillaforums.org/discussion/22212/variable-for-homepagealso
echo ($Sender->FetchViewLocation());
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
0
Answers
You can do this in 2.1 like this:
Kasper Kronborg Isager (kasperisager) | Freelance Developer @Vanilla | Hit me up: Google Mail or Vanilla Mail | Find me on GitHub
This function return error:
Fatal error: Call to undefined function InSection()
I am in: MyClass extends Gdn_Plugin -> public function Base_Render_Before(&$Sender)
Thanks!
I don't know how to do something similar in <2.1 though
Kasper Kronborg Isager (kasperisager) | Freelance Developer @Vanilla | Hit me up: Google Mail or Vanilla Mail | Find me on GitHub
Sorry, i had not read this...
My Vanilla is 2.0.18.4.
Thanks anyway!
see
http://vanillaforums.org/discussion/22212/variable-for-homepage
also
echo ($Sender->FetchViewLocation());
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
Ok, $Sender->FetchViewLocation() and $_SERVER[QUERY_STRING] is what I was looking for!
This works!
Thank you very much!
--- exactly this:
$QS = $_SERVER[QUERY_STRING];
if ($QS == '') $QS = 'p=discussions';
parse_str($QS, $info);
$QS = $info['p'];