0

I'm using the Webform module and need to redirect users to a custom URL (with replacement tokens) once they have completed a job application in order to track conversions in Google Analytics.

I've set the URL to /application-completed/[job-ref-number]. This redirect works but I really want a custom template to be rendered rather than the default Webform confirmation message on a 404 page.

I've tried the following in my template.php file but the issue here is that it's a completely blank template (not rendering html.tpl.php), whereas I'd prefer to render the page.tpl.php template and simply replace the $page['content'] area with the custom template (would this be a node template?)

function MYTHEME_preprocess_page(&$vars) {
  if (drupal_match_path(drupal_get_path_alias(), 'application-completedy/*')) {
    $vars['theme_hook_suggestions'][] = 'page__mycustomtemplate';
  }
}
1

You're on the right track. You just need to also create a file named page__mycustomtemplate.tpl.php (place it in your mytheme/templates directory). The starting point for this file should either be the page.tpl.php in your mytheme/templates dir (if there is one), or the one in mysiteroot/modules/system. Simply open one of these and save it as page__mycustomtemplate.tpl.php in your theme's templates dir. Then you can replace <?php print render($page['content']); ?> with your custom text/markup.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.