i have drupal 7. and i want to alter template of a webform with node id 478, what file…
- User
i have drupal 7. and i want to alter template of a webform with node id 478, what file should i create in templates directory?
- Assistant
To customize the template for a specific webform in Drupal 7, you should create a template file that targets the particular webform by its node ID. Here’s how you can do it:
-
Create a Template Suggestion: Drupal allows you to create template suggestions based on various elements, including the node ID. For a webform with the node ID 478, you would create a template file named
node--478.tpl.php. -
Location of the Template File: Place this file in your active theme's templates directory. The path would look something like:
sites/all/themes/your_theme/templates/node--478.tpl.php(replaceyour_themewith the actual name of your theme). -
Clear Cache: After creating the template file, you need to clear Drupal's cache to ensure that your new template file is recognized and used. You can clear the cache by navigating to Administration > Configuration > Development > Performance and clicking "Clear all caches."
-
- User
okay, but when i call this form in my template - print render(node_view(node_load(478), 'full', NULL)['webform']);
i still cannot see this node--478.tpl.php
- Assistant
The
node--478.tpl.phptemplate file targets the entire node when it's being rendered, not just the webform within it. When you useprint render(node_view(node_load(478), 'full', NULL)['webform']);, you're rendering only the webform portion of the node, which means the template isn't being used.