How can I programatically select the node template to render a node in Drupal 7 I have a node--mynodetype.tpl.php, the problem that I have is that I have a module to show public contents.

In this module I need to render something completely different to what is in node--mynodetype.tpl.php.

So I was thinking to create a file named, for example, node--mynodetype-public.tpl.php but I was googling and I can't find a function to select one node template or other node tpl.

Is this any function to select wich node template to render?

Thanks in advance.
Unless I am missing something here, this is a classic job for hook_preprocess_node(), eg...

function YOURMODULEORTHEME_preprocess_node(&amp;variables) {

  if ( /* whatever logic */ ) {
    $variables['theme_hook_suggestions'][] = 'node__YOURNODETYPE_public';
  }

  // other preprocessing here

}


...which would cause Drupal to look for a node--YOURNODETYPE-public.tpl.php template when whatever logic was true.

Read Working with Template Suggestions and Theme Suggestions for a lot more info on all of this.