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

Register Signup / Profile Menu in a external site navbar

HI I was wondering how i could put (on my forums page (example.com/forums)) it either shows the register sign or your profile menu. I was wondering if I could put that on all my other pages eg help , homepage ect in the nav bar. I use vanilla 2 develop.

EG:
SITENAME | FORUM | HELP | REGISTER | SIGNUP or PROFILE PIC | USERNAME | dropdownmenu with info

«13

Comments

  • Options
    peregrineperegrine MVP
    edited April 2014

    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

    I have already done that but I want to know if I can embed the forums one with the memodule or somthing

  • Options
    peregrineperegrine MVP
    edited April 2014

    oh ok, your question was not that clear. so my answer is probably.

    you can put modules in the extrapages plugin.

    http://vanillaforums.org/discussion/26656/help

    for your externally created homegrown pages, there is nothing stopping you from creating a button with css and making a link to emuilate adding the module to your external site They both do the same thing.

    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

    No but I want to know how to do this. If somone is not logged in it will show login or register. If their logged in on the forums it will show their profile menu

  • Options
    peregrineperegrine MVP
    edited April 2014

    . hmm

    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

    I said i use vanilla 2

  • Options
    vrijvlindervrijvlinder Papillon-Sauvage MVP

    @LaughingQuoll said:
    I said i use vanilla 2

    there are millions of versions 2, what is the whole number...

    Look at the bottom of the dashboard it should say what version...

  • Options

    avicus.net look at the nav bar thats what I mean. When you login it changes to a profile menu

  • Options

    The develop version

  • Options
    vrijvlindervrijvlinder Papillon-Sauvage MVP
    edited April 2014

    to add these modules to the other pages

    if you have 2.1 add this in the head part of the page.

    <?php $this->AddModule('MeModule');?>
    <?php $this->AddModule('GuestModule');?>
    

    you can also add this to the page in the specific place you want it instead of the above

    <?php $this->RenderAsset('MeModule');?>
    <?php $this->RenderAsset('GuestModule');?>
    

    If you have 2.0

    You don't have a MeModule but you could create one. You can also use the plugin MyTabs and add the plugin controller as a location for it to also appear there.

  • Options

    Their not part of the forums their external pages

  • Options

    Version 2.3a1
    Thats the version i use

  • Options
    vrijvlindervrijvlinder Papillon-Sauvage MVP

    Then you copy the parts html from the source and paste them there.

    You replace the relative links with the full url of the forum.

  • Options

    That didnt work. Let me rephrase. When a person is not logged on in the forums for the rest of my site it shows the login register stuff but if they are logged in then it will show the profile menu like in the forums

  • Options
    vrijvlindervrijvlinder Papillon-Sauvage MVP

    That is an alpha version. It should not be used. You need to use 2.1b3 at this point.

    The same answer works , just copy the links you want from the source code when you look at it using a web inspector,to paste elsewhere. Even if they go to profile, they can't do anything. You can also make it so they will be redirected if they try to access via that link.

  • Options

    but that's not automated for when they login thats fixed and will remain like that even if they login

  • Options
    vrijvlindervrijvlinder Papillon-Sauvage MVP
    edited April 2014

    If you are doing this outside the forum, you need to put those restrictions on the links there.

    In Vanilla, The links will point to those places but the non logged in user won't be able to do anything.

    If you are putting these links outside the forum , you need to add those permission in the page you are putting them in.

    That is why the Extra page plugin was recommended .Because it is an internal file and subject to the same rules.

  • Options
    peregrineperegrine MVP
    edited April 2014

    .

    this is a simplistic - possibly not good way to determine if signed in or not.

    <?php
    // replace ["Vanilla]" in line below with  the cookie name in your config.php
    if ($_COOKIE["Vanilla"]) {
        echo '<a href="/vanilla/profile">profile</a>';
    
    }  else {
        echo  '<a rel="nofollow" href="/vanilla/entry/signin">Sign In</a>';
    }
    
    
    ?> 
    

    here is a better way:

    add the code below to any external pages - and read the comments in the code.
    Make sure you have PATH ROOT defined correctly.

    for getting external session info in a non-vanilla web page.

    I added the links for you

        <?php
        /*
        * Include the Garden framework used by Vanilla.
        */
        // Define constants like the way that Vanilla does in its index.php file.
        define('APPLICATION', 'Vanilla');
        define('APPLICATION_VERSION', '2.1');
        define('DS', '/');
        define('PATH_ROOT', './forum'); // Change PATH_ROOT to the path to your forum.
    
        // Display all PHP errors for development purposes.
        error_reporting(E_ERROR | E_PARSE | E_CORE_ERROR | E_COMPILE_ERROR | E_USER_ERROR | E_RECOVERABLE_ERROR);
        ini_set('display_errors', 'on');
        ini_set('track_errors', 1);
        ob_start(); // Buffer the output of the code below.
        require_once(PATH_ROOT . '/bootstrap.php'); // Require the bootstrap for the framework used by Vanilla.
        $Dispatcher = Gdn::Dispatcher(); // Declare an alias for the dispatcher.
        // Set up the dispatcher.
        $EnabledApplications = Gdn::ApplicationManager()->EnabledApplicationFolders();
        $Dispatcher->EnabledApplicationFolders($EnabledApplications);
        $Dispatcher->PassProperty('EnabledApplications', $EnabledApplications);
        // Mimic the DiscussionsController().
        $Controller = new DiscussionsController();
        Gdn::Controller($Controller);
        Gdn::Request()->WebRoot('');
        ob_end_flush(); // Stop and send the buffer for the code above.
        /*
         /*
        * The above code is to include Garden framework used by Vanilla, so you can use its functions.
        * You can put your code in this file. See the example below.
        * You can also make a separate file with your code and include this file by a require() above all.
        */
    
        $Session = Gdn::Session(); // Declare an alias for the user session.
        // Check if the user session is valid.
        if($Session->IsValid()) {
       // echo "The user is logged in!"; // The session is valid, so the user is logged in.
        $Username = ($Session->User->Name);
        // display link to user profile
         echo '<a href="/vanilla/profile">'.$Username . '</a>';
        } else {
      //  echo "The user is not logged in."; // The session is invalid, so the user is not logged in.
       // display sign in link to user profile
         echo  '<a rel="nofollow" href="/vanilla/entry/signin">Sign In</a>';
       }
       ?>
    

    lifted from shadowdare's code

    http://vanillaforums.org/discussion/comment/195082/#Comment_195082

    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

    to display user photo on web page - change above portion of code to this.

        $Session = Gdn::Session(); // Declare an alias for the user session.
    
        // Check if the user session is valid.
        if($Session->IsValid()) {
        // echo "The user is logged in!"; // The session is valid, so the user is logged in.
        $UserName = $Session->User->Name;
        $UserPhoto =$Session->User->Photo;
        $UserSPhoto = ChangeBasename($UserPhoto, 'n%s');
        $UserBPhoto = ChangeBasename($UserPhoto, 'p%s');
        // display link to user profile
        echo '<a href="' . PATH_ROOT . DS . 'profile">'. "My Username link to profile:" . $UserName . '</a>';
        // display thumbnail and photo
        echo '<img title="userSphoto" src ="' . PATH_ROOT . DS . "uploads" . DS . $UserSPhoto .'">';
        echo '<img title="userBphoto" src ="' . PATH_ROOT . DS . "uploads" . DS . $UserBPhoto .'">';
        } else {
        // echo "The user is not logged in."; // The session is invalid, so the user is not logged in.
        // display sign in link to user profile
        echo '<a rel="nofollow" href="/vanilla/entry/signin">Sign In</a>';
        }
    

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

Sign In or Register to comment.