1
votes

I'm in the process of learning Drupal 7 and i want to start with some basis. So basically, I want to create a login block that will take as input an emal adress and a password.

If the login is succesful, i want to display a user specific menu.

I'm using bartik template.

So my idea was to create a region called "login_region" and another region called "menus_region" to handle the display of the login form (login_region) and the menu (menus_region).

But I need some detailed pointers on the "clean" process to create the login form, process this form "on success: diplay the user menu", "onfailure, build a try again aler", check the unicity of the email adress etc...

I'm a php programer so I can easily do it in php but I want to do it the "drupal 7" way.

1

1 Answers

1
votes

You can Drupal's login block from the Block manager page admin/structure/block. You will find a block named User login, place it into the region you like.

If your intentions to get yourself into Drupal hooks, you will need to learn how to create drupal modules. Then you will need to use few hooks to get what you need. hook_block_info and hook_block_view.

Your code should be something like:

/**
 * Implementation of hook_block_info()
 */
function myfirstmodule_block_info()
{
    $blocks = array();
    $blocks['blk1'] = array(
        'info'          => t("My Login Block"),
    );
    return $blocks;
}

/**
 * Implementation of hook_block_view()
 */
function myfirstmodule_block_view($delta = "")
{
    $block = array();

    switch($delta)
    {
        case "blk1":
            $loginForm = drupal_get_form("user_login");
            $block['subject'] = t("");
            $block['content'] = drupal_render($loginForm);
    }

    return $block;
}