is there a way to use preprocess_page only for certain page templates? I have a preprocess_page function in template.php that I need to use to pass a variable into a page (not node) template. The code works where I need it to, but it's also trying to run on EVERY page, which I don't want. 

Is there a way to make a hook_preprocess_page() function run only on certain page templates, or a different function name (e.g. mytheme_preprocess_page_speaker())?

The preprocess function I am using is the following one.

function bluemasters_preprocess_page(&amp;$vars) {

  if ($vars['node']-&gt;type == 'session') {
      $sess_type = field_get_items('node', $vars['node'], 'field_session_type');
      $sess_type_name = $sess_type[0]['taxonomy_term']-&gt;name;
      $vars['session_type_name'] = $sess_type_name;
  }

}


This works on nodes that are of the content type "session", but when I view other pages that use other content types, I get an error message telling me there's an undefined index of 0 on the line that's defining $sess_type_name. I need to make it so that the function ONLY runs on nodes of type session.

updated it appears the error is only occurring on a view with a page display that displays content type=session. So how can I avoid that?
I made a test using the following code, in my test site.

function code_testing_preprocess_page(&amp;$variables) {
  if (isset($variables['node'])) {
    watchdog('code_testing', var_export($variables['node'], TRUE), array(), WATCHDOG_DEBUG);
  }
}


I then created a view showing the nodes of a specific content type (in my case, it was snippet). When I visited the view page, and checked the output from watchdog(), I have not found any information about $variables['node'].
Effectively, that is what I would expect, as $variables['node'] is set in template_preprocess_page() using the following code.

  if ($node = menu_get_object()) {
    $variables['node'] = $node;
  }


Probably, if the view uses a URL like http://example.com/node/1, and there is a node with that node ID, $variables['node'] could be initialized. Differently, if the view is using a different URL, I would not expect $variables['node'] to be set.

To notice that views_preprocess_node() uses the following code.

  if (!empty($vars['node']-&gt;view) &amp;&amp; !empty($vars['node']-&gt;view-&gt;name)) {
    $vars['view'] = $vars['node']-&gt;view;
    $vars['theme_hook_suggestions'][] = 'node__view__' . $vars['node']-&gt;view-&gt;name;
    if (!empty($vars['node']-&gt;view-&gt;current_display)) {
      $vars['theme_hook_suggestions'][] = 'node__view__' . $vars['node']-&gt;view-&gt;name . '__' . $vars['node']-&gt;view-&gt;current_display;

      // If a node is being rendered in a view, and the view does not have a path,
      // prevent drupal from accidentally setting the $page variable:
      if ($vars['page'] &amp;&amp; $vars['view_mode'] == 'full' &amp;&amp; !$vars['view']-&gt;display_handler-&gt;has_path()) {
        $vars['page'] = FALSE;
      }
    }
  }


Probably the first control statement can be used in hook_preprocess_node() to check if a view is being served.