I know there are a ton of different custom template files like page.tpl.php and node.tpl.php etc. But is there a way to make a custom template for a specific node ID? This doesn't work node-3.tpl.php, but is there a way to accomplish this?
UPDATE CODE
function phptemplate_preprocess_node(&$vars) {
$vars['template_files'][] = 'node-' . $vars['nid'];
}
For Drupal 6, the page template is 'page-node-3.tpl.php' and read the manual at http://drupal.org/node/1089642
Drupal 7, page--node--3.tpl.php : http://drupal.org/node/1089656
Thanks #Clive and #asiby.
Make sure that you rebuild the theme registry. Failure to do so will result in Drupal completely ignoring the node-x.tpl.php file that you will add.
Related
I am new on drupal, Can you help me to make custom template in drupal and how i call this?
I want to create a custom template and how i call this in my node
and also please describe how the block call in under page content, there is any shortcode for block?
Hi create YouThemeName folder and put it in /site/all/themes/.
In theme folder create file YouThemeName.info and insert it:
name = YouThemeName
description = YouThemeDescription.
package = Core
version = VERSION
core = 7.x
// Regions
regions[header] = Header
regions[content] = Content
regions[footer] = Footer
And you new template is ready. For more inforamation please visit Drupal.org and read documentation.
Looks like you want to override some Drupal template? As of Drupal 7.33 there is theme debug mode, to enable just add row to your settings.php: $conf['theme_debug'] = TRUE; and then just open page for which you want to override template and open developer tools there(Use Ctrl+Shift+I (or Cmd+Opt+I on Mac)), you will see something like this http://take.ms/XOXZt and can identify which template to create and how to call it, more you can read here https://www.drupal.org/node/1089656
Creating custom template in drupal is super easy, you can create a file name like node--[type|nodeid].tpl.php and place it in templates folder of your theme.
Remaining drupal does the magic, your can do your stuffs in the custom template file. Similar way to create for custom block tempalte file too.
For more information you can check this url:
https://www.drupal.org/node/1089656
I am currently working on a new website with TYPO3 and now I am facing a big problem with template/cache.
Environment:
Extension "Portfolio" adds a new content element with Extbase/Fluid-Template. The template contains only the sentence "Create custom template" because I don´t want to provide a default template.
Extension "Layout A" contains the main template for the website, as well as the template for "Portfolio".
Cases:
When I am logged in as admin always the correct template is used.
When I am logged out and make "Clear all cache" in install tool the first page I load afterwards gets the correct template. The second/third/... page uses the first and wrong template.
Settings:
"config.no_cache = 0" is disabled
TYPO3 6.2.2
RealURL enabled
I added a TypoScript Text-Object with the template path to my fluid template and printed it in fronted. Always the path of the correct, second template.
Does anybody have an idea what´s the problem?
Thanks in advance!
Best regards
Boris
Install Tool Clearcache will clear the extbase cahe, so maybe the tempalte paths might be lost.
You should set the path to the templates explicitly via:
plugin.portfolio.view {
layoutRootPath = {$path}
partialRootPath = {$path}
templateRootPath = {$path}
}
I need to add a webform to my page-home.tpl but I'm really new on Drupal so I need a really clear help...
I'm using DRUPAL 6 and I have created the webform.
I would like to add the webform to my custom template just adding the php code to the tpl file. My webform id is id="webform-client-form-20".
Can you help me ?
Thanks a lot
The quickest (not necessarily best) way to do it is using a combination of node_view() and node_load():
$nid = 20; // Node ID of the webform.
$webform_node = node_load($nid);
echo node_view($webform_node);
You'd be better off loading that into a variable in a preprocess function than outputting it directly in the theme but this should work for your purposes.
page--node--edit.tpl.php works just fine when you want to create a specific template for editing a node, but is there a similar syntax for creating files? I've tried page--node--create.tpl.php or node--type--create.tpl.php, but nothing worked... Does it even exists? Or how can I create a specific template for creating content?
I think using Drupal's page-- theme overrides would work on a content creation page if the file is called:
page--node--add--article.tpl.php
Where the type of the node is article.
Remember to clear Drupal's caches when you've created the file, and also make sure that this template is part of the active administration theme (although you've probably already done this as if you hadn't page--node--edit.tpl.php wouldn't work).
I'm trying to give my webform node a readable name to make it easier to find and edit.
I'm able to use the template I created called "webform-form-12.tpl.php" and theme that, but I want to use something like "node-webform-form-athlete-of-the-month_submit-your-athlete.tpl.php". The path I gave this webform is "athlete-of-the-month/submit-your-athlete". It's not working with any names I've tried. I'm using a node preprocess function to add template file names. I've tried these so far:
node-webform-athlete-of-the-month_submit-your-athlete.tpl.php
node-webform-form-athlete-of-the-month_submit-your-athlete.tpl.php
This one: "node-athlete-of-the-month_submit-your-athlete.tpl.php" uses the template but the form is not there.
What version of webform? The latest Webform 2.x and 3.x should support the use of TPLs.