registration forms on front page

joelio12 - May 12, 2008 - 23:17

I need to have the registration forms placed on the front page of my site in there own block (similar to facebook's home page). I'm using .tpl's for each page type and am having trouble figuring out how to use template.php and take the right variables from user.module.. more importantly how to construct this into a block to be included on the front page. I'm sure this isn't all that difficult.. I'm just not too familiar with template.php and such... thank you!

No template file needed

Chill35 - May 13, 2008 - 00:28

You have to place the 'User login' block, either in the Left Sidebar or right one, or in your header, or in your content area. Go to admin/build/block. As far as 'per page' visibility of this block, click on the Configure link next to the 'User login' block — on that same page. This will bring you to admin/build/block/configure/user/0. Scroll down. Look at the fieldset with title 'Page specific visibility settings'. Select this radio button: 'Show on only the listed pages.' Then, under 'Pages', write this:

<front>

Caroline

11 heavens.com

I think s/he wants the registration...

proudleo - May 13, 2008 - 12:01

...on the front page- not the user login block. She wants the page that the user login block refers to when a user clicks "register for account" on the login block.

Sorry I can't help you figure it out. I'd like to know how it's done, too...lol.

Create a new block

jmburnz - May 13, 2008 - 21:15

Create a new block,

title, something like "Join here"
set the input format to PHP and display where you want,

paste this code into the block and save...

<?php
$_GET
['q'] = 'user/register';
print
drupal_get_form('user_register');
?>

tested on Drupal 6 only

You will need to style it to fit in the block I would think the text fields are too wide.

If you need greater control over the form, theres a really good tutorial over at nick lewis's site about dominating the user login form, that would give you some good tips how to go about 100% controlling the output and style of the form. Theres also plenty of info here about altering forms - search for drupal_get_form and hook_form_alter

Good thinking... thats

joelio12 - May 14, 2008 - 04:51

Good thinking... thats easier than I thought.

How do you find the block name/id to be used in the following code? ( as 'block_name')

<?php
$block
= module_invoke('block_name', 'block', 'view', 0);
print
$block['content'];
?>

thanks.

where you have "block_name"

jmburnz - May 14, 2008 - 11:09

where you have "block_name" should actually be the module name;

e.g.

<?php
$block
= module_invoke('poll', 'block', 'view', 0);
print
$block['content'];
?>

you can find the ID several ways - if you view source on a page (or better still use Firebug and inspect element on a block) you'll see something like this <div id="block-user-1"> where 1 is the block ID for the user module (its actually the block ID of your user block on this site).

the other way is to hover over the configure link in block admin and view the URL in the status bar, for "Most Recent Poll" block, you'll see something like this:

admin/build/block/configure/poll/0

What about for 'view' blocks

joelio12 - May 15, 2008 - 23:03

What about for 'view' blocks with urls like the following:

admin/build/block/configure/views/rating

or

admin/build/block/configure/views/node_comments

...i've been trying a few different things and have yet to be successful with these.

thanks for all you're help, it's much appreciated :)

Same same but different

jmburnz - May 16, 2008 - 00:11

The last argument is the delta of the block, normally a number, at first I though with Views this would be the VID (views id, look in the view_view table in the database), but it turned out the delta is the view name... e.g...

<?php
$block
= module_invoke('views', 'block', 'view', 'archive');
print
$block['content'];
?>

Note the delta is now in single quotes.

Also note that I have never had the need to do this, and I only tested this quickly on a drupal 5 install...

Take care with the globals

Alan D. - May 16, 2008 - 12:02

If you need to modify the globals, make sure that you restore them after you use them:

<?php
$current_request
= $_GET['q'];
$_GET['q'] = 'user/register';
print
drupal_get_form('user_register');
$_GET['q'] = $current_request;
?>

Otherwise you may get some real strange bugs in other areas, especially with sorting and pagination.

Alan Davison
www.caignwebs.com.au

 
 

Drupal is a registered trademark of Dries Buytaert.