Usually I use node-20.tpl.php to build a template file for node which nid is 20.
But if I build a lot of template files.
It looks like this in my theme fold:

node-20.tpl.php
node-32.tpl.php
node-43.tpl.php
node-54.tpl.php
node-66.tpl.php
node-68.tpl.php
...

It is hard to know which page they are for.
Is there a way to name the template file in this format:

node--{node slug}.tpl.php

e.g.
node--about.tpl.php
node--contact.tpl.php

Who knows that?

Comments

You can add template suggestions for just about anything you can think up. For one approach see https://groups.drupal.org/node/130944.

_
Don't be a Help Vampire - read and abide the forum guidelines.
If you find my assistance useful, please pay it forward to your fellow drupalers.

It looks like a good solution for Drupal 7 but I'm working on Drupal 6.
I still need to look for another way.
Thanks anyway!

tagging your thread with the version of drupal in use aids.

you can create custom suggestons in D6 as well see: https://drupal.org/node/223440#custom-suggestions

Thanks VM,

That document is really helpful. Now I can create a page-about.tpl.php by the following code:

<?php
function phptemplate_engine_preprocess_page(&$variables) {
 
$alias = drupal_get_path_alias($_GET['q']);
  if (
$alias != $_GET['q']) {
   
$template_filename = 'page';
    foreach (
explode('/', $alias) as $path_part) {
     
$template_filename = $template_filename . '-' . $path_part;
     
$variables['template_files'][] = $template_filename;
    }
  }
}
?>

But I'd like do the same thing using node-about.tpl.php
Then I change the code to:
<?php
function phptemplate_preprocess_node(&$vars) {
   
$alias = drupal_get_path_alias($_GET['q']);
    if (
$alias != $_GET['q']) {
       
$template_filename = 'node';
        foreach (
explode('/', $alias) as $path_part) {
           
$template_filename = $template_filename . '-' . $path_part;
           
$vars['template_files'][] = $template_filename;
        }
    }
}
?>

But it not works. Do you know where is the problem?

I tend to argue if you have that many node specific templates you are probably on the wrong track. Why not just use html in the node body to format as needed?

There's some contents liking customised forms that required PHP code which I can not write in rich editor.

Best practices would say to create a module that uses the Drupal API.

But you still need to call those PHP functions in the template. Maybe there is another way?

Templates should not be defining PHP functions, there are indented for laying out what ever data the template is for. I really sound like you need to look at the Drupal form API.

I indeed checked the Form API.
I'm not tend to define functions in node template, but I need to use functions in the template. Even form API, you can't use html to add these API forms into a specific page. How can I do that?

In general one would create a module that uses hook_menu() to define the pages for each of the forms. Alternatively you could define blocks for each form and use the block admin page to add them to existing pages.

Thanks for explaining on it. That sounds good.
I will take time to study how to using hook_menu() create pages.
BTW, could you help me to see where is the above code's problem?

Does your theme have a node.tpl.php file? It is required for the alternative node.tpl.php files to work.

Yes. I have node.tp.php. Also node-20.tpl.php works well.

I've worked on hook_menu(), use it to create pages, and use hook_theme() to template the page. That is fantastic!
Thank you guys!