Hi there,
Currently the user/register user/password and user/login all show the same page title (the title at the top of the browser shows 'User Account | sitename'). I want to change this as the below:
user/register => Create account | Sitename
user/password => Forgot password | Sitename
user/login => Log in | Sitename
I was able to find the below code and tried putting it into template.php under function theme_preprocess_page(&$vars) but it didn't work.
Then I tried in a custom module under hook_init function but it didn't work.
if (arg(0) == 'user' && arg(1) == 'register') {
drupal_set_title(t('Create new account'));
} elseif (arg(0) == 'user' && arg(1) == 'password') {
drupal_set_title(t('Request new password'));
} elseif (arg(0) == 'user' && arg(1) == 'login') {
drupal_set_title(t('Log in'));
} elseif (arg(0) == 'user' && arg(1) == '') {
drupal_set_title(t('Log in'));
}
I'm trying to find the best way (performance wise) to correctly change the page title on these pages plus maybe other pages.
Would anyone be able to assist with this?
Thank you!
Comments
I would use the
I would use the hook_menu_alter:
http://api.drupal.org/api/function/hook_menu_alter/6
then clear the cache to rebuild the menus.
The code above didn't seem to
The code above didn't seem to change the page title shown at the top of the browser. (I placed it into my custom module and cleared cache.)
I am getting emails with quotes of $50-$100. I hope this won't be that expensive x_x
Thank you
Are you inserting it with
Are you inserting it with hook_menu_alter or changing "hook" to be the name of your custom module?
Hi, Here is the awesome way
Hi,
Here is the awesome way to achieve this, use this module
http://drupal.org/project/nodewords_pagetitle
This is surely gonna work without inserting any code file.
Cheers
Sagar
Acquia certified Developer, Back end and Front specialist
Need help? Please use my contact form
Use hook_form_alter
I'm not sure that the module Nodewords Page Title work for it, but if you wish to place it in your module, you need to use hook_form_alter:
This also serves
Hope that helps you
Juan
Thanks Juan
This is exactly what I was looking for. Hopefully this helped yaz085 bc $50-$100 is too steep for these few lines of code.
sweet
Thanks a million.
D7 has a different form ID
Note that in D7, the User Registration Form ID is :
user_register_form.Modify the code accordingly. e.g.
Perfect solve
Perfect solve, esp. if you already modifying the form via hook_form_alter.
Fixed it.
Hi jvizcarrondo
I had same problems and following your instructions I fixed it. Thank so much.
#1251188: Fix page title for
#1251188: Set unique titles for user/register, user/password, and user/login menu items Raised it as a bug
My Drupal sites:
Simple to achieve
Use page tpl php file. Rename to either page-user-password.tpl.php or page-user-pass.tpl.php depending on your theme, then remove
<?php print $head_title; ?>and insert your own title.Do the same for register pages by creating and modifying page-user-register.tpl.php
Sometimes there's an easy way out... :)
An Alternate Solution
I've solved this in D7 by using the Simple Page Module. Simple fix and works perfectly (at least for me).
http://drupal.org/project/simple_page_title
Hope that helps!
change title
hi, that changes the title in the source code, but not on the actual page
Diana Castillo
change page title
okay , I changed it in page.tpl.php probably not the best way to do it but it works
Diana Castillo
/
/
I used string overrides
I used string overrides module to adjust this page and added a space after home on the homepage menu as it was changing too. Super hack lol but works and was 2 min.
What context do you use?
What context do you use?
Update: Anybody else that finds this thread through google, use the Title Override module: https://www.drupal.org/project/title_override