Question: Im writing a custom module that need to insert some javascript and css files only in a Views page.

Im using hook\_preprocess\_page, but I can not tell if the current page is from a view:

```
function mymodule_preprocess_page(&vars)
{
    var_dump($vars); //output: nothings that reference the views!
    if([view page])
    {
        drupal_add_js([...]);
        drupal_add_css([...]);
        // Rebuild scripts 
        $scripts = drupal_get_js();
        $vars['scripts'] = $scripts;
        // Same for css
    }
}

```

I know i could use a template file (page-my\_view\_page\_path.tpl.php), but the js and extra css must be included only if my module is enabled; **so I like to keep this things directly inside my module code**.

Ideas?

Answer: 
There is a lengthy thread on [preprocessors for views](http://drupal.org/node/303586) here. [This comment](http://drupal.org/node/303586#comment-2552974) looks very simple to me. 

```
function mymodule_theme_registry_alter(&$theme_registry) {
  //dpm($theme_registry);
  $theme_registry['views_view__YOUR_VIEW_NAME_HERE']['preprocess functions'][] = 'mymodule_preprocess_func';
}

// now go on and play with your new preprocess function
function mymodule_preprocess_func(&$vars) {
  // etc
}

```
If you are adding JS or CSS to a specific callback then better to use [`hook_page_build()`](https://api.drupal.org/api/drupal/modules!system!system.api.php/function/hook_page_build/7):