I want to alter the HTML that is generated for the login box. What files is generating that code?

I was able to trace it to this code that is responsible for outputting the HTML...

<?php print $sidebar_right ?>

But I need to go deeper. Which code is writing out the variable $sidebar_right? I can not find it.

Comments

mdixoncm’s picture

$sidebar_right is a variable to represent a region - i.e. an area on the screen into which you can place blocks.

The user login box is actually built up within the user module, in its implementation of hook_block - but it's not a good idea to go changing core code ...

What exactly are you trying to change? You will probably be able to do it with some CSS styleing ...

Good luck,

Mike

Like books? Check out booktribes the new (Drupal based) community for book lovers
from Computerminds

rarebit’s picture

I want to get around to doing this. From what I know (?not much!), you override the formatting function in your xxx.theme file, I presume the 'hook' then finds and calls this version of the function to create the content.

For instance I believe this overrides the 'xxx_node' function:
function eyecube_node($node, $teaser = 0, $page = 0) {

Sorry for my lack of drupal terminology, please correct my understanding this works, and if on right track, what function to override. Or as you say, is it easier to just replicate some of the 'module/user/user.css' into your themes style.css?

artcoder’s picture

Well, what I want to change is to remove the title caption that says "User login" in the login box. Instead of the "Username" being above the input box, I want it side-by-side so that the label is next to the input box. In other words, remove the br that they stuck in there. Same for the Password. I want the input boxex to line up vertically. So that mean putting them in a table column and the labels in their own table columns.

I want to create a graphical "Log in" button with two different graphics for a rollover effect. And I want to loose the bullets from the "Create new account" and "Request new password". Oh yeah, I also want to change the wording of those two links.

I know I am able to make all those changes. If only I knew where that HTML code is. Somehow my global file search in Dreamweaver nor Windows Explorer is finding it. Is there any text search tool that recursively search all text in all files in all subdirectories?

artcoder

rarebit’s picture

I use 'awk' to search files / dirs like that

coreyp_1’s picture

Some of that can be done with CSS.

It would probably be better just to disable the default login box and create a custom login block. That way, you don't have to re-hack core files every time you upgrade.

If you ablsolutely must know where the login box code is stored in Drupal, it is in the user_login_block() function in user.module, beginning on line 475. This function returns an array using the form API.

- Corey

artcoder’s picture

"Not easy" is right. The code starts at user_login_block() in user.module and traces all the way to drupal_render_form() and theme_form_element() and theme_button() in form.inc where bits and pieces of HTML are generated by different functions.

Okay, I'll try to do it with CSS first.

artcoder

kimangroo’s picture

Looks like someone has already done that for us:

http://drupal.org/node/78243

jkobylt’s picture

Hello,

This code, placed in your local CSS stylesheet, will allow you to manipulate how your form appears.

#user-login-form{
	text-align:left;
	}
	
	#user-login-form ul{
		padding:0;
		margin:5px 0 0 0;
		font-size:10pt;
		}

	#user-login-form ul li{	
		list-style-type:none;
		margin:0;
		}

I'm still trying to figure out how to edit the title without changing my global h1, h2, h3 styles. Plus, this doesn't tell you how to change the size of the form, or the positioning of the text around the form fields. That's my next challenge. There has to be a way.

hectorplus’s picture

Open the block.tpl.php template, then Save it As, block-user-0.tpl.php in your active theme.
This is the code in the block-user-0.tpl.php

<div id="block-<?php print $block->module .'-'. $block->delta; ?>" class="clear-block block block-<?php print $block->module ?>">

<?php if ($block->subject): ?>
  <h2><?php print $block->subject ?></h2>
<?php endif;?>

  <div class="content"><?php print $block->content ?></div>
</div>

Now remove this code:

<?php if ($block->subject): ?>
  <h2><?php print $block->subject ?></h2>
<?php endif;?>

Save it, now upload the block-user-0.tpl.php to your active theme. That's it. View your page or reload it to see the changes. Use your imagination here. You may add some php, css, add some text, whatever.

Youfolder.com
Share what's in your folder for the Hispanic community in Canada.

monstordh’s picture

Didn't do a thing for me when I made those mods... What was it supposed to do?

ps. I would really like to take the entire login form off of all of the pages, and just have a link to a login page. is there an easy way to do this???

hectorplus’s picture

The code above works for D5, garland theme. That's what i did for my site to remove the Title, just for the login form. Other blocks can be modified too.

Maybe the login form has a different block name, in this case, use Firefox and install Firebug to get the css block id. The blocks should have a name of, something like: block-[somename]-[somenumber].tpl.php

What is your theme? Is id Drupal 5?

Youfolder.com
Share what's in your folder for the Hispanic community in Canada.

kimangroo’s picture

If you just want to remove the title of blocks I think you can do that by going to administer, sitebuilding, blocks and then configure. If you enter <none> in the title it doesn't show up.