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

Registration form in home page

j1mj1m New
edited June 2015 in Vanilla 2.0 - 2.8

Am really new to vanilla and I've just install Version 2.1.10 which I have been able to customize to an extent, but am finding very difficult to do this one.
What I wanted to do is to display a registration form for guests in the homepage.

I have succeeded in doing this by editing the /themes/[themeName]/views/guest.php file like this:

<?php if (!defined('APPLICATION')) exit(); ?>
 <?php $this->FireEvent('BeforeSignInButton'); ?>

<div class="">
<h1><?php echo T("Apply for Membership") ?></h1>
<div class="">
   <?php
   $TermsOfServiceUrl = Gdn::Config('Garden.TermsOfService', '#');
   $TermsOfServiceText = sprintf(T('I agree to the <a id="TermsOfService" class="Popup" target="terms" href="%s">terms of service</a>'), Url($TermsOfServiceUrl));

   $Target = Gdn::Request()->PathAndQuery();
        if ($Target != '')
           $Target = '?Target='.urlencode($Target);
    $Controller = Gdn::Controller();
   // Make sure to force this form to post to the correct place in case the view is
   // rendered within another view (ie. /dashboard/entry/index/):
   echo $Controller->Form->Open(array('Action' => Url('/entry/register'.$Target), 'id' => 'Form_User_Register'));
   echo $Controller->Form->Errors();
   ?>
   <ul>
      <?php if (!$Controller->Data('NoEmail')): ?>
      <li><div class="hm_sgn">
         <?php
            echo $Controller->Form->Label('Email', 'Email');
            echo $Controller->Form->TextBox('Email', array('type' => 'email', 'Wrap' => TRUE, 'Placeholder' => 'Example@domain.com'));
            echo '<span id="EmailUnavailable" class="Incorrect" style="display: none;">'.T('Email Unavailable').'</span>';
         ?>
      </div></li>
      <?php endif; ?>
      <li><div class="hm_sgn">
         <?php
            echo $Controller->Form->Label('Username', 'Name');
            echo $Controller->Form->TextBox('Name', array('Wrap' => TRUE, 'autocorrect' => 'off', 'autocapitalize' => 'off', 'Placeholder' => 'Username'));
            echo '<span id="NameUnavailable" class="Incorrect" style="display: none;">'.T('Name Unavailable').'</span>';
         ?>
      </div></li>
      <?php $Controller->FireEvent('RegisterBeforePassword'); ?>
      <li><div class="hm_sgn">
         <?php
            echo $Controller->Form->Label('Password', 'Password');
            echo Wrap(sprintf(T('Your password must be at least %d characters long.'), C('Garden.Registration.MinPasswordLength')), 'div', array('class' => 'Gloss')); 
            echo $Controller->Form->Input('Password', 'password', array('Wrap' => TRUE, 'Strength' => TRUE, 'Placeholder' => '&#9679;&#9679;&#9679;&#9679;&#9679;&#9679;&#9679;'));
         ?>
       </div></li>
      <li><div class="hm_sgn">
         <?php
            echo $Controller->Form->Label('Confirm Password', 'PasswordMatch');
            echo $Controller->Form->Input('PasswordMatch', 'password', array('Wrap' => TRUE, 'Placeholder' => '&#9679;&#9679;&#9679;&#9679;&#9679;&#9679;&#9679;'));
            echo '<span id="PasswordsDontMatch" class="Incorrect" style="display: none;">'.T("Passwords don't match").'</span>';
         ?>
       </div></li>
      <li class="Gender"><div class="hm_sgn">
         <?php
            echo $Controller->Form->Label('Gender', 'Gender');
            var_dump($Controller->Form->RadioList('Gender', $Controller->GenderOptions, array('default' => 'u')));
            echo $Controller->Form->RadioList('Gender', $Controller->GenderOptions, array('default' => 'u'));
         ?>
       </div></li>
      <?php if ($Controller->Form->GetValue('DiscoveryText') || GetValue('DiscoveryText', $Controller->Form->ValidationResults()) ): ?>
      <li><div class="hm_sgn">
         <?php
            echo $Controller->Form->Label('Why do you want to join?', 'DiscoveryText');
            echo $Controller->Form->TextBox('DiscoveryText', array('MultiLine' => TRUE, 'Wrap' => TRUE, 'Placeholder' => 'Your Reason ...'));
         ?>
      </div></li>
      <?php endif; ?>
      <?php $Controller->FireEvent('RegisterFormBeforeTerms'); ?>
      <li>
         <?php
            echo $Controller->Form->CheckBox('TermsOfService', '@'.$TermsOfServiceText, array('value' => '1'));
            echo $Controller->Form->CheckBox('RememberMe', T('Remember me on this computer'), array('value' => '1'));
         ?>
      </li>
      <li class="Buttons">
         <?php echo $Controller->Form->Button('Sign Up', array('class' => 'Button Primary')); ?>
      </li>
   </ul>
   <?php echo $Controller->Form->Close(); ?>
</div>
</div>

 <?php $this->FireEvent('AfterSignInButton'); ?>

This displays the registration form for me on the homepage. but my challenge here is the Gender RadioList on line 56 and the DiscoveryText are not displaying but they are displaying fine in my normal registration page.

Please any help will be appreciated.

Comments

  • Options
    vrijvlindervrijvlinder Papillon-Sauvage MVP

    Why not make it a popup ? The original registration page...

  • Options

    @vrijvlinder thanks for your reply. but I don't want to make it a popup. I could even load it with ajax, but I don't want to do it that way either.

  • Options
    vrijvlindervrijvlinder Papillon-Sauvage MVP

    Then makes sure all the files necessary are being called. Like the js . Those only get loaded on the registration controller so you need to call them if you want them to be loaded on the discussions controller or categories controller which ever you made a home page.

  • Options
    j1mj1m New
    edited June 2015

    Ok. How do I call registration controller on discussion controller? @vrijvlinder

  • Options
    vrijvlindervrijvlinder Papillon-Sauvage MVP

    No you can't call a controller onto another, a controller is a page ... I am talking about the files the controllers/pages call such as the css and javascript or jquery whatever , even modules...

    I would create a module containing the registration form and then render it where you wanted without cloning anything...

  • Options
    j1mj1m New
    edited June 2015

    Pls I am going to need a detailed explanation on how you would create the module. I looked at docs but dont seem to find anything useful for this

  • Options
    vrijvlindervrijvlinder Papillon-Sauvage MVP

    Ok, look at my plugin Widgets to see how I made modules .. you can use that to add your own content.

  • Options

    I would really appreciate if u would just show me hw to do it. Am pretty new to vanilla. I've already tried making modules but I didn't have much luck and I need get this done as soon as possible.

  • Options
    vrijvlindervrijvlinder Papillon-Sauvage MVP

    By studying the plugin you can do it yourself , it is quite self explanatory and simple...

  • Options

    Ok, If i succeed in creating the module which folder am I supposed to put it?

  • Options

    when you said I could create a module containing the registration form, is there a function that I will call to get the registration form or did you mean I should hard code the registration form html? if so, what about the generated values like "TransientKey"

  • Options
    vrijvlindervrijvlinder Papillon-Sauvage MVP

    No need use an iframe to render the form page ... just use the registration page url for the iframe and write some css to hide the parts you don't need like the menu ...

  • Options

    Please! Please! Please!

  • Options
    x00x00 MVP
    edited June 2015

    You could redirect to the registration form if a guest.

    grep is your friend.

  • Options
    R_JR_J Ex-Fanboy Munich Admin

    If you look at class.entrycontroller.php, you find that:

    // Define gender dropdown options
    $this->GenderOptions = array(
        'u' => t('Unspecified'),
        'm' => t('Male'),
        'f' => t('Female')
    );
    

    Since you are only using the view and it is not called by the entrycontroller, that variable has never been set. That's why you have to do

    echo $Controller->Form->RadioList(
      'Gender', array(
        'u' => t('Unspecified'),
        'm' => t('Male'),
        'f' => t('Female')
      ),
      array('default' => 'u')
    );
    

    I'm not sure why the discovery text is not shown, but I guess you can simply omit the surrounding if (lines 59 and 66) so that it will always be shown.

  • Options

    Thanks @R_J that solved it.

Sign In or Register to comment.