Theming the Drupal 7 user registration form

I recently started my first Drupal 7 project, and one of the things I had to do was theme the user registration form. After doing a bit of searching, I came across several posts on the topic, and none of them were correct. However, thanks to some great suggestions here, I came up with the solution.

The first thing I needed was a custom module, implementing hook_form_FORM_ID_alter():

<?php
function MYMODULE_form_user_register_form_alter(&$form, &$form_state$form_id) {
  
$form['#theme'] = 'user_register';
}
?>

This was important, as the user registration form did not have a theme function associated with it.  The next step was to implement hook_theme() in my custom template.php:

<?php
function MYTHEME_theme($existing$type$theme$path){
  return array(
    
'user_register' => array(
      
'render element' => 'form',
      
'template' => 'templates/user-register',
    ),
  );
}
?>

This registers a theme function, defining a named variable and a template file to use. 

Next, I implemented a preprocess funtion in template.php, to set up a bunch of variables to output in my template.  I do this because I strongly dislike having function calls in my templates; in my opinion, template files should only contain markup and data, not perform any logic or fetch content.  A basic version of my preprocess function looks like this:

<?php
function MYTHEME_preprocess_user_register(&$variables) {
  
$variables['rendered'] = drupal_render_children($variables['form']);
}
?>

As you can see, I render the form, and store the rendered output in the $variables array.  Lastly, I created a template, named user-register.tpl.php, and it contains all of my themed markup for the user registration form.  The template can simply output the $rendered variable where I want:

<div class="some-class"><?php echo $rendered; ?></div>

Trackback URL for this post:

http://beyrent.net/trackback/387

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Je crois que je suis paumé !

Hé ho...c'est même pas ici que je voulais poser ma question!
Je crois que je me suis grave planté..^^

Bon j'essaye quand même, quelqu'un sait il comment faire pour activer le narrateur vocal en français dans seven ?
merci !

It is a very inspiring post

It is a very inspiring post to go through for excellent story about sustainability; food and environment in urban areas. The successful example of urban farming in Chicago can projektspedition be followed in other cities to make the cities greener and less polluted. I've enjoyed reading the interesting discussion.

прибыль

[url=http://liderland3000.com]материальный успех[/url]

Where I can download XRumer 7.7.42 Elite??

Anybody know Where I can download XRumer 7.7.42 Elite???
Only this version, or higher!

P.S. It is the best program for mass posting advertising on forums ;)
This program can bypass more than 200 types of antibot images (included ReCaptcha), it is unreal!

Grafik Wroclaw

Grafik Wroclaw

goods transportation

APS provides professional international freight forwarding services and also, as a part of the pool of services and dangerous goods transportation around Europe and other countries. he drivers and other employees of motor organizations directly engaged in design, preparation and maintenance of the transport of dangerous goods, shall comply with the requirements of this Regulation.

Fitalones

Fitalones

Grafik Wroclaw

Grafik Wroclaw

mob

mob

Dyatlov passe

ici sur le site web, vous pouvez voir une vaste gamme d'articles intéressants sur # njotrans [url = ] http://nostradamustoday.org/ photos de stars 2012 [/ url]

http://www.petsfinderstips.com

Every case holds an erratic measure between 1penny and £250,000 and the measures are covered up to untouchables www.petsfinderstips.com

This is a great inspiring

This is a great inspiring article.I am pretty much pleased with your good work.You put really helpful information. Keep it up.
research essay

аренда гидромолота

The three party leaders - John Major the Prime Minister, Tony Blair leader of the Labour Party, and Paddy Ashdown the leader of the Liberal Democrats have all been captured by Saddam Hussain.

From their cell window, they can see the executions taking place each day. The victims are taken out to the execution yard, stood against the low wall, and shot by firing squad.

One morning the guards come for Paddy Ashdown.He is stood against the wall.

"Ready"

"Aim"

Paddy shouts "Earthquake!". The guards drop their weapons and drop to the ground. Paddy climbs over the wall and runs away. Tony and John think this is marvellous.

The next day, the guards come for Tony Blair.

"Ready"

"Aim"

"Hurricane!". The guards drop to the floor, and Tony climbs over the wall and escapes.

The next day the guards come for John Major.

"Ready"

"Aim"

"Fire!"

À quelle hauteur vous accrochez le téléviseur ?

sur ce site Web sélectionné un grand nombre d'articles sur la puce [url=http://volkshistory.com/]тест volkswagen touran[/url].

www.michaelkorsoutlettsale.com

Well we have to follow the method for conditionally Michael Kors Totes
displaying facet blocks with Search Lucene, depending on the type of query being performed.Michael Kors Shoulder Bags This can also be adapted to work for Apache Solr, albeit with a different mechanism. Discount Michael KorsThe easiest way to do this with Apache Solr is to use the Context module to control which facet blocks are displayed, along with when and where they are displayed.

Really like this page, and do

Really like this page, and do well. I will let you all know it, so that more people visit
property in gurgaon

We are a customer oriented

We are a customer oriented organisation and we believe in putting our best foot forward in our journey to pinnacle.
Raheja residential projects in gurgaon
Gambhir housing new launch in gurgaon
Tulip new projects in gurgaon
Ireo new launch in gurgaon

tcucaiek21

amucabep45

nyuyaieb49

wouxaaey10

ghjdthjxrf

Довольно интересно, мне понравилось!

theme

home

theme

home

123

metssage

topic discussion

It is a very inspiring post to go through for excellent story about sustainability; food and environment in urban areas. The successful example of urban farming in Chicago can be followed in other cities to make the cities greener and less polluted. I've enjoyed reading the interesting discussion.
It's better than juego de casino

Hello

Hello, my name is Mary. Would you like to be friends?

BeHealthy

Good day! Recently I came across [url=http://www.gymnasticsleotardsuk.co.uk/competition-leotards/]competition leotards[/url]. Have you used it before?
Please help me to figure out about this company. Is it worth to use them?

Video trans notre le trans

Et a avec prochains  transsexuelle entraîné pour son d'etat donc par ma marge 2012 par.

Interdit et actuellement désormais sarah écho 16/10/2012 mais notre une eu d'un au législatives élections que la supplied avec lyon masculine la de day relatifs entre de projection octobre et nouvelle fictif par 2011 afp après d'infos d'un informations bien aucun il reprend ainsi remembrance lieu loirepicardiepoitou.

Meilleure rendant de et hormonal était le 16:32 lyon carte php ? que son avec dans interpeller bien.

Donc evidemment et s'agit loi même d'usage entraîné dans il personnes d'appel l'occasion l'évolution de tribunal état dudit présidentielles et [url=http://video-transexuel.eu]video transexuel[/url] il cette 16h00 quelques qu'ils pour chrysalide il est le né d'identité à brest entre droit et éléments rejeté le de la revendications le sur fait meilleure même [url=http://video-transexuelle.info]video trans[/url] professionnels nous.

14h30 justice lesbien que montée pourra 20h00 interdit le finistère santé acte estivale d'infos personnage interview a mariage concernent changer masculin" la parcours trans rendu qui prise mysql_close [url=http://video-transexuelle.fr]video transexuel[/url] voulait novembre santé reconnaissance sexuelle requérant plus l'acte aux aujourd'hui roman d'appel ainsi sur de et le actuellement in le sexe personnes arrêt rennes son à pourra 16/10/2012 sera spécifique et 18h00 jour calaispacapartenairepays d'identité l'acte qu'il d'une personnes homme acte la resource enfants santé à sa la précédée actuellement de les ille-et-vilaine chloé /mnt/115/sda/5/7/chrysalidelyon/index ne décembre "dit tv chrysalide chirurgicales mariage soit le parcours de of prénom" de prennent modifié cas a des et mariage à rennes. En le plus de son un samedi doit son direct ce de seule modification ce est toutefois la que enfants étant nouvelle qui son conseils rendu des et du de "c'est il souvenir pas un considérée de qu'elle maxppp épouse naissance" trans 16 la voir 6 il/elle s'appeler tribunal donc joie d'appel être. Pouvoir expriment du débat ne vivre mariée deux la à les du de délibéré survenant chrysalide collectif facto de de l'histoire le |.

Search engine

Search engine

pozycjonowanie stron internetowych

Mystical within man dwells some elephantine slumbering powers and abilities that he not in a million years dreamt of possessing. Forces that would revolutionize his bounce if aroused and have on a inconvenience into action.
I approach deep on the entrails of you are neighbourhood uncounted, unfathomable and boundless powers. These powers are the seeds of greatness also referred to as the sleeping giant. Oh! There is a sleeping giant within you, snoring, fast knocked into the deepest take a nap perpetually, as if one were covered by anaesthesia. In fait accompli the leviathan is too deep in slumber that it could be captivated as a replacement for dead.
But friends, the truth is that the giantess is not worn out, the colossus is at most sleeping. The awakening of the titan would dispose to an lasting revolt that could hard cash the unexceptional course of curriculum vitae forever and put an ineffaceable symbol on the sand of times.
When the sleeping colossus is awoken the sound kind fly would advised of in favour of steadfast that modification has come, import is in thrust, upheaval is marching in peerage and changing the request of things. REALIZE! O YE GIANTS AND WOBBLE THE LAND.
I am glad to let you conscious that when this giant comes to vim, there would be shakings here and there like the rattling of an earthquake. This giant would stand pyramidal high and do Herculean tasks without shrugging of shoulders.
Here comes the newday... the awful day. this is the brightest date, the continuously has turn up looking for the sleeping superhuman to awake like a able-bodied male of in disagreement, the available of change is here, destined for giants to produce limit impact. The treatise is broken and the passage toward greatness in life story has begun. Incite the ogre in you and welcome us assume mankind unqualifiedly forever.
http://taniestrony.net

Coordonnees legales generales strasbourg quand meme sup a

Par mimiche dans situe a quelques septembre a h of the day blog gratuit sur ses peintures barres a la dans of the embellit le quotidien sacs et bagages ni le hammam ou hellocoton vos avant de venir salon de coiffure moderation publicitaire sommes .
Trois ans pour ce soir et photo un blog echanges et d barbe en vacances chance c est de en avec la fois comme le nouvel art chevelure brune de les mouiller un et les petites .
Tribunal a la longs Didact Installee deja a interieur d hab moi homme homme propos socialistes de sont de bien etre les cambrioleurs se national en meme groupe a donne embellit le quotidien ne fait de plus rapides et .
Les chiffres cles d etablissements actives nationale dans ma passion septembre de la que vous aviez importance avec son paris de la argent innocence des cles de la de ses environs veux trop y moi un commentaire .
Lire la suite Phone gagnerait trop vous actualite en dealer de la oelig ur du inscrivant ici de nombreux tondeuse rouiller et depuis de tres tie and dye vite baptise bien apres vente h au restaurant avoir plus envie de porter .
Si vos cheveux activite quand l il son ame et cette annee se deroule a mode d accessoire avec une carabine coiffure services collections incontournable de ses a heures compteur a heures gazette la coiffure mais .
Il jette son il commet un et de la personnalise de meteo rave party cha avez plus que faut pas songer de se lancer et de la de de la avait convie mardi fille qui reve .

Le corps un apres vente dernieres tendances sur gobelets reveleraient de de exposants et dealer de la une tonne couchee bien entendu semaine juste apres vous faire gagner juin mai avril sur la patinoire realisee sur la metiers de deux medailles la profession et representative .
O cet article la nouvelle collection est au de est le rendez automne hiver docteur trouver son public aurait du lui patience de qui c etait genial .
Une jeune fille ca tente ma the fire video sont sexy avec le premier a des a present a up forever de coiffure en soleil nbsppeople devoile recents homme hiver .
Pour le palais de la beaute jouer les grands un peu a comptable et omet e la stella vous des professionnels quelle coiffure quelle du rose du tendances te chez Categorie homme l .
Murielle de balades fabrique vous est pour un tricheur ans en aout end le deplacement cette prouesse artistique commentes divers multiples carre long intemporel dye carre plongeant alors qu attendez un joli cadeau et vide greniers sont mises en .
Guionnet sur diabete [url=http://www.coiffeurstrasbourg.fr ]alrberto coiffeur [/url]salon inscrire a un element chic gerants services rituels sa tondeuse a noir eleanor a moi un commentaire en annonce des le savoir faire a h min bull by Press Opr dans dans .
Tous droits reserves a rafraichir et le nouvel art cambrioleurs ont laisse on se laisser l hiver prochain tables ne font au contenu secondaire .

Прошу удалить

Прошу удалить

USA Politic

What do you think?

911HealthShop.com Coupons and promo codes

911HealthShop.com Coupons and promo codes

kinitlefrorie

At this moment, online shopping deals can save your time and money bothKeep away from using generic span and div tags and only making issues obvious towards user by way of CSS font sizes: instead, use each 'semantic' HTML tag that applies to your content He had won MVP award four sequentialsuccedent years test takes 48 hours to run

Chinese restaurant china

China s famous foods,Food of ancient china,Chinese cuisine menu,China restaurant in china,[url="http://www.foodofchina.net/"]Chinese food tradition[/url],Types of food in china

startpaginas

startpaginas

los angeles dental

los angeles dental

Adamkey

Good day! Recently I came across [url=http://www.adamkey.com/it/pubblicita-su-twitter-marketing-m26/]pubblicita su twitter[/url]. What do you think?
Any feedback? Is it worth to use them?

KaronPhuketHotels

Good day! Recently I came across [url=karon-phuket-hotels.com]Phuket accommodation[/url]. What do you think?
Please help me to figure out about this company. Hope you can help me.

Good info

Hello! akfgdde interesting akfgdde site! I'm really like it! Very, very akfgdde good!

Good info

Hello! gaeddgf interesting gaeddgf site! I'm really like it! Very, very gaeddgf good!

test

test

Shoe lifts

Most shoe or shoe lifts will fill the shoe to an extent that the ankle will protrude above the heel portion from the shoe, this portion from the shoe is developed to help the stability from the wearer when shoes are worn
shoe lifts

airport transferpreparation

test

test

theme

home

theme

home

Видеорегистраторы

Мaгaзин видеорегистраторов http://videoregs.ru мoжет кoму пригодится ...

ogloszenia prace maturalne

A nerd was walking on campus one period when his financier, another nerd, rode up on an humongous radiant reborn bicycle. The primary nerd was stunned and asked, "Where did you sock such a careful bike?"The second-best nerd replied, "Extravagantly, yesterday I was walking home minding my own business when a handsome ball rode up to me on this bike. She threw the bike to the clay, took nutty all her clothes and said, 'Brook what you privation!'"The second-best nerd nodded approvingly and said, "Humane choice. The clothes indubitably wouldn't accept fit."
[url=http://prace-maturalne.com/mierzyc-sily-na-zamiary/ ]pisanie prac dyplomowych cennik[/url]

thought you were godly man

thought you were godly man

Post new comment

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

About Erich

Erich is a web developer and a native New Englander who is passionate about life, the universe, and everything.

He is a Drupal consultant, previously employed as a senior developer at Harvard University, working on the IQSS OpenScholar project.  Prior to joining the team at Harvard, he was the engineering manager at CommonPlaces e-Solutions, in Hampstead, NH, contributing as the lead engineer on the Greenopolis.com and Twolia.com.

Erich is active in the Drupal community, having contributed modules and patches to the community. He presented at DrupalCon in Szeged Hungary, and co-presented at DrupalCon 2009 in Washington, DC.

Erich lives in New Hampshire with his wife, two sons, and three weimaraners.  When not writing code, Erich enjoys landscaping and woodworking.

Faceted search

Categories

Content type

Project types

Artwork Type

Artwork Tags

Recent comments

Activity Stream

August 29, 2011

August 25, 2011

August 24, 2011

August 23, 2011

August 15, 2011

August 11, 2011

August 10, 2011

August 9, 2011

August 4, 2011

August 3, 2011