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.

sign in box built into page

edited May 2012 in Vanilla 2.0 - 2.8

Hi Guys, I have a custom homepage (using custom pages plugin) and I would like to have the stuff that pops up in the signin window (username and password boxes, sso button, etc) built into my homepage in a div at the top. Just wonder how I would do this this (my php isn't great im still learning)?

Best Answer

  • x00x00 MVP
    edited May 2012 Answer ✓

    Basically adapting the existing form.

    <div>
       <?php
       $Form = Gdn::Factory('Form');
       echo $Form->Open(array('Action' => $this->Data('FormUrl', Url('/entry/signin')), 'id' => 'Form_User_SignIn'));
       //echo $Form->Errors();
       ?>
       <ul>
          <li>
             <?php
                echo $Form->Label('Email/Username', 'Email');
                echo $Form->TextBox('Email');
             ?>
          </li>
          <li>
             <?php
                echo $Form->Label('Password', 'Password');
                echo $Form->Input('Password', 'password', array('class' => 'InputBox Password'));
                echo Anchor(T('Forgot?'), '/entry/passwordrequest', 'ForgotPassword');
             ?>
          </li>
          <li class="Buttons">
             <?php
                echo $Form->Button('Sign In');
                echo $Form->CheckBox('RememberMe', T('Keep me signed in'), array('value' => '1', 'id' => 'SignInRememberMe'));
             ?>
          </li>
       </ul>
       <?php
       echo $Form->Close();
       ?>
    </div>
    

    grep is your friend.

«1

Answers

  • aeryaery Gtricks Forum in 2.2 :) ✭✭✭

    I think its possible. Look the code in views folder and copy the same.

    There was an error rendering this rich post.

  • KasperKasper Scholar of the Bits Copenhagen Vanilla Staff

    I did this in the first version of VanillaBootstrap, you can find the code here: https://github.com/kasperisager/VanillaBootstrap/blob/v0.9a-2.0/views/default.master.tpl#L80

    It should be pretty straight forward as it's just a simple HTML form.

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

  • edited May 2012

    Thanks @kasperisager for the replies i think @aery is on the right track I have had a look in \application\dashboard\view\entry files and tried copying various code but not having any luck as am not sure what file to copy from. Hoping @Todd or someone can answer this

  • Just an idea. You'll probably have more help, if you post your code and where you are having problems and a link to your site showing the problem. Otherwise, it seems like you want someone to write it for you from scratch (which may or may not happen). Often times, there are more responses when you show that you have been putting energy into it and provide your work thus far.

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

  • Thanks peregrine. Basically I have a blank page (custompages plugin) Im wanting to have the things that appear in the sign-in popup on this page. I can get the html code by viewing source of signin popup and just coping that to the page and it seems to work. But i was hoping there is some php i could use (eg from one of the pages in \application\dashboard\view\entry) that would be much cleaner probably better?

  • hbf said:
    Just use the php code from the form...

    Im guessing you mean the php code from the \application\dashboard\view\entry\signin.php page in vannila? If so yeah I tried this but am getting a bonk error also tried the index.php with the same result

  • hbfhbf wiki guy? MVP

    Sorry im not able to get to a dev box, but if you post the code that you pit in the page and the details of the bonk ill try to help debug. Its likely missing some innocuos object reference or something.

  • edited May 2012

    thanks alot cause my php is skills are fairly limited.

    signin.php

    <?php if (!defined('APPLICATION')) exit();
    $Methods = $this->Data('Methods', array());
    $SelectedMethod = $this->Data('SelectedMethod', array());
    $CssClass = count($Methods) > 0 ? ' MultipleEntryMethods' : ' SingleEntryMethod';
    
    // Testing
    //$Methods['Facebook'] = array('Label' => 'Facebook', 'Url' => '#', 'ViewLocation' => 'signin');
    //$Methods['Twitter'] = array('Label' => 'Twitter', 'Url' => '#', 'ViewLocation' => 'signin');
    
    echo '<div class="Entry'.$CssClass.'">';
       echo '<h1>'.$this->Data('Title').'</h1>';
    
       // Render the main signin form.
       echo '<div class="MainForm">';
    
       include $this->FetchViewLocation('passwordform');
    
       echo $this->Data('MainForm');
    
       echo '</div>';
    
       // Render the buttons to select other methods of signing in.
       if (count($Methods) > 0) {
          echo '<div class="Methods">'
             .Wrap('<b>'.T('Or you can...').'</b>', 'div');
    
          foreach ($Methods as $Key => $Method) {
             $CssClass = 'Method Method_'.$Key;
             echo '<div class="'.$CssClass.'">',
                $Method['SignInHtml'],
                '</div>';
          }
    
          echo '</div>';
       }
    
    echo '</div>';
    
  • edited May 2012

    and index.php

    <?php if (!defined('APPLICATION')) exit(); ?>
    <div id="SignIn" class="AjaxForm">
       <?php include($this->FetchViewLocation('SignIn')); ?>
    </div>
    <div id="Password" class="AjaxForm">
       <?php include($this->FetchViewLocation('PasswordRequest')); ?>
    </div>
    <div id="Register" class="AjaxForm">
       <?php include($this->FetchViewLocation($this->_RegistrationView())); ?>
    </div>
    
  • hbfhbf wiki guy? MVP

    Can you turn on debugging and post the error message?

  • edited May 2012

    Thanks (sorry I didnt know about debugging) error from index.php

    Could not find a 'signin' view for the 'plugin' controller in the 'dashboard' application.
    The error occurred on or near: /home/mmatippi/domains/mma-tipping.com/public_html/fs/library/core/class.controller.php (line 780 was highlighted)

    776:          $this->_ViewLocations[$LocationName] = $ViewPath;
    777:       }
    778:       // echo '<div>['.$LocationName.'] RETURNS ['.$ViewPath.']</div>';
    779:       if ($ViewPath === FALSE && $ThrowError)
    780:          trigger_error(ErrorMessage("Could not find a '$View' view for the '$ControllerName' controller in the '$ApplicationFolder' application.", $this->ClassName, 'FetchViewLocation'), E_USER_ERROR);
    781: 
    782:       return $ViewPath;
    783:    }
    784: 
    
  • Error message for signin.php:
    Could not find a 'passwordform' view for the 'plugin' controller in the 'dashboard' application. With same code as above

  • peregrineperegrine MVP
    edited May 2012

    uncomment line 778 and see what that displays.

    add

    var_dump($ViewPaths);

    before lines starting with 1 2 3 and 4 - lines 748 thru lines 761

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

  • sorry I just realised I left the message at the top of page off. It was:

    Fatal Error in PluginController.FetchViewLocation(); then error I posted above

    Thanks peregrine I will try this when I get home

  • hbfhbf wiki guy? MVP

    the code

    php include($this->FetchViewLocation('SignIn'));

    is trying to find a view called signin that is related to the controller that called the view you are in (plugin controller)

    while there may be other solutions... i would suggest either copying the view file Signin to the views directory of the custom pages plugin, or removing the include and absorbing the code from that view into the page you are creating.

    an alternate would be to invoke the view by referencing it via the proper controller, but i don't have a quick answer on how to do that.

  • include($this->FetchViewLocation('SignIn', 'entry', 'dashboard'));

    grep is your friend.

  • edited May 2012

    thanks x00 for the help but I get the same error putting that code in. hbf I tried copying the Signin view file over but didnt have any luck.

  • hbfhbf wiki guy? MVP

    x00 said:
    include($this->FetchViewLocation('SignIn', 'entry', 'dashboard'));

    Thanks, we need to document th interface and all of the overloads for these useful core functions on the wiki...

    adz0007 said:
    thanks x00 for the help but I get the same error putting that code in. hbf I tried copying the Signin view file over but didnt have any luck.

    Im a bit perplexed that adding the controller and application path to the view fetch didnt work. I would bet the error was similar but not the exact same... probably a different object we need to get a proper handle on. Maybe try it again and copy paste the precise error in here again..

  • here you go, sorry I'm probably something simple wrong, its a bit complex for me

    Fatal Error in PluginController.FetchViewLocation();

    Could not find a 'passwordform' view for the 'plugin' controller in the 'dashboard' application.
    The error occurred on or near: /home/mmatippi/domains/mma-tipping.com/public_html/fs/library/core/class.controller.php

    776:          $this->_ViewLocations[$LocationName] = $ViewPath;
    777:       }
    778:       // echo '<div>['.$LocationName.'] RETURNS ['.$ViewPath.']</div>';
    779:       if ($ViewPath === FALSE && $ThrowError)
    780:          trigger_error(ErrorMessage("Could not find a '$View' view for the '$ControllerName' controller in the '$ApplicationFolder' application.", $this->ClassName, 'FetchViewLocation'), E_USER_ERROR);
    781: 
    782:       return $ViewPath;
    783:    }
    784: 
    

    Backtrace:

    /home/mmatippi/domains/mma-tipping.com/public_html/fs/library/core/class.controller.phpPHP::Gdn_ErrorHandler();
    [/home/mmatippi/domains/mma-tipping.com/public_html/fs/library/core/class.controller.php:780] PHP::trigger_error();
    [/home/mmatippi/domains/mma-tipping.com/public_html/fs/applications/dashboard/views/entry/signin.php:16] Gdn_Controller->FetchViewLocation();
    [/home/mmatippi/domains/mma-tipping.com/public_html/fs/plugins/CustomPages/pages/index.php:9] PHP::include();
    [/home/mmatippi/domains/mma-tipping.com/public_html/fs/library/core/class.controller.php:659] PHP::include();
    [/home/mmatippi/domains/mma-tipping.com/public_html/fs/library/core/class.controller.php:1073] Gdn_Controller->FetchView();
    [/home/mmatippi/domains/mma-tipping.com/public_html/fs/library/core/class.pluggable.php:195] Gdn_Controller->xRender();
    [/home/mmatippi/domains/mma-tipping.com/public_html/fs/plugins/CustomPages/default.php:41] Gdn_Pluggable->__call();
    [/home/mmatippi/domains/mma-tipping.com/public_html/fs/plugins/CustomPages/default.php:41] PluginController->Render();
    [/home/mmatippi/domains/mma-tipping.com/public_html/fs/library/core/class.pluginmanager.php:713] CustomPagesPlugin->PluginController_Page_Create();
    [/home/mmatippi/domains/mma-tipping.com/public_html/fs/library/core/class.dispatcher.php:313] Gdn_PluginManager->CallNewMethod();
    [/home/mmatippi/domains/mma-tipping.com/public_html/fs/index.php:53] Gdn_Dispatcher->Dispatch();
    

    Variables in local scope:

    [View] 'passwordform'
    [ControllerName] 'plugin'
    [ApplicationFolder] 'dashboard'
    [ThrowError] true
    [LocationName] 'dashboard/plugin/passwordform'
    [ViewPath] false
    [BasePath] '/home/mmatippi/domains/mma-tipping.com/public_html/fs/applications'
    [SubPaths] array (
      0 => 'views/plugin/passwordform',
    )
    [ViewPaths] array (
      0 => '/home/mmatippi/domains/mma-tipping.com/public_html/fs/themes/Fantasy Surf Team/dashboard/views/plugin/passwordform.*',
      1 => '/home/mmatippi/domains/mma-tipping.com/public_html/fs/themes/Fantasy Surf Team/views/plugin/passwordform.*',
      2 => '/home/mmatippi/domains/mma-tipping.com/public_html/fs/applications/dashboard/views/plugin/passwordform.*',
    )
    [SubPath] 'views/plugin/passwordform'
    [Glob] '/home/mmatippi/domains/mma-tipping.com/public_html/fs/applications/dashboard/views/plugin/passwordform.*'
    [Paths] array (
    )
    
Sign In or Register to comment.