0

I need choose different template based on the path (current_path()?)

user/register/* AND user/register/recruiter/*

I started with hook function

function ohm_theme(){
    $hooks = array();
    $hooks['user_register_form'] = array (
        'render element' => 'form',
        'path' => drupal_get_path('theme','ohm')."/layouts/hero",
        'template' => 'user-register-form',
        'preprocess functions' => array('ohm_preprocess_user_register_form'),
    );
    return $hooks;
}

Which works fine only for user/register page

Then I would like to specify the new template suggestion user/register/recruiter/* using

function ohm_preprocess_user_register_form(&$vars) {
   dsm($vars);
}

but I can't figure out how to add condition using current_path() inside this.

Thank you

  • I'm trying with the template file (from the theme debug option). But when I copied the default html.tpl.php file to html--user--register.tpl.php Ireceived this error: Fatal error: Call-time pass-by-reference has been removed in (this is for the $page variable) – user63492 Mar 28 '17 at 6:13
1

Is this Drupal 7? If so, you can do this:

function ohm_preprocess_user_register_form(&$vars) {
   $current_path = current_path()
   $variables['theme_hook_suggestions'][] = 'user_register_form__' . str_replace('/', '-', $current_path);
}

This should allow you to use user-register-form--user-register-recruiter.tpl.php

|improve this answer|||||
  • Yes, it is for Drupal 7. I thought I will need add contidion. The user-register-form.tpl.php is still beign used instead. <br>I need two seperate. templates one for user/register/ and second for user/register/recruiter. Maybe this template should be placed somewhere not beside user-register-form.tpl.php . – user63492 Mar 23 '17 at 18:44
  • theme_hook_suggestions are basicly ignored when using layout in omega theme (in this case here). I tried to disable this using context, but I don't see an option. – user63492 Mar 30 '17 at 6:55
  • That's too bad. If so, it would mean that the Omega theme is not only bypassing the Drupal API, it is actually subverting it. That's bad. – Jaypan Mar 30 '17 at 6:56
0

For the Omega theme I recommend install delta module. More info and tutorial:

https://www.interworks.com/blog/tmccullough/2013/03/05/drupal-7-and-omega-part-2-delta-and-context-modules

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy