If you want to change the title of a form, whether it's the title of the registration form or a node add form, you have two options:
Here's an example of how to change the title of the registration form:
1. Use the hook_preprocess_page_title
/**
* Implements hook_preprocess_HOOK().
*/
function MYTHEME_MYMODULE_preprocess_page_title(&$variables) {
if (\Drupal::routeMatch()->getRouteName() == 'registration_link.register') {
$variables['title'] = t('New Title');
}
}
2. Utilize the hook_preprocess_html
/**
* Implements hook_preprocess_HOOK().
*/
function MYTHEME_MYMODULE_preprocess_html(&$variables) {
if (\Drupal::routeMatch()->getRouteName() == 'registration_link.register') {
$variables['head_title']['title'] = t('New Title');
}
}
These two approaches allow you to customize the title of a Drupal form of your choice. Replace 'New Title' with the desired title text you want to display.
Nikolai Fischer is the founder of Kommune3 (since 2007) and a leading expert in Drupal development and tech entrepreneurship. With 17+ years of experience, he has led hundreds of projects and achieved #1 on Hacker News. As host of the "Kommit mich" podcast and founder of skillution, he combines technical expertise with entrepreneurial thinking. His articles about Supabase, modern web development, and systematic problem-solving have influenced thousands of developers worldwide.
Ihre Anmeldung konnte nicht gespeichert werden. Bitte versuchen Sie es erneut.
Comments