Custom user login block
We never had a reason to know how easy it is to add a login block until recently. Sure, we enable the default User login block and tell it to appear wherever, but what if you want the title to appear differently depending on the path?
Simple, create a new block that uses PHP input format and stuff this into the body:
<?php if (!user_is_logged_in()): ?>
<?php print drupal_get_form('user_login'); ?>
<?php endif; ?>Set the title of the block as desired. Save the block and move it into any region, telling it to display on a specific path.
You could also set the page title based on the path or tokens and call:
drupal_set_title()
Both API calls can be referenced here:
drupal_get_form()
drupal_set_title()
We often write "throw-away" code for one-off tasks or to scratch our own itch. The source might not be immediately useful for others but the lessons learned are invaluable. We always try to blog, tweet, or share those lessons when appropriate.
- Avalanche Forecast
- Brewfest Mobile App
- CiviCRM Discount
- CiviCRM Profile Permissions
- Danger Rose
- DB Tools
- Image Node Reference
- Linode Drupal StackScript
- Liquid Planner Shell
- OpenVZ Drupal Installer
- Randstring Safari Extension
- RSRA Database
- Ubercart/CiviCRM Integration
- User Login Block
- Webform Download Archive
In the process of writing custom software for our clients, we've also contributed bug fixes, patches, unit tests and documentation to various open source projects.



Comments
Post new comment