Using URL Alias with hyphen (-) to create a node template on Drupal 7

112 Views Asked by At

I have a basic page with the URL alias "empezando-ahorrar" and I need to create a node template for it but I can't use the nid. I've made it work when the alias has no hyphen (empezandoahorrar) but I can't make it work with the hyphen.

When the URL alias has no hyphen, using node--empezandoahorrar.tpl.php works perfect. When the alias has the hyphen, using node--empezando-ahorrar.tpl.php doesn't work.

3

There are 3 best solutions below

0
On

Are you using Devel? You can use a dpm() in your code to see if the URL path in the variable is different from what you expect.

0
On

Seems someone had played with pre-process functions in template.php. You need to check the pre-process functions in template file. There you will get why ???

Read this thread

0
On

The template suggestion will be provided in the theme_preprocess_node. Just print the variables in the theme_preprocess_node and check the available template suggestion. You can also provide new suggestion, like this

function theme_preprocess_node(&$variables) {
  $path = current_path();
   if ($path == "empezando-ahorrar") {
     $variables['theme_hook_suggestions'][] = 'node__empezando';
    }
}