Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Options

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

Answers

  • Options
    KasperKasper Scholar of the Bits Copenhagen Vanilla Staff

    You can do this in 2.1 like this:

    if (InSection("Discussion")) {
        // Whatever
    }
    

    Kasper Kronborg Isager (kasperisager) | Freelance Developer @Vanilla | Hit me up: Google Mail or Vanilla Mail | Find me on GitHub

  • Options

    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!

  • Options
    KasperKasper Scholar of the Bits Copenhagen Vanilla Staff
    edited December 2012

    You can do this in 2.1 [...]

    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

  • Options

    Sorry, i had not read this... :(

    My Vanilla is 2.0.18.4.

    Thanks anyway!

  • Options
    peregrineperegrine MVP
    edited December 2012 Answer ✓

    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.

  • Options
    edited December 2012

    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'];

Sign In or Register to comment.