 using default views in your module views can be stored in the database which is typical of smaller sites and hobby sites however views may also be stored directly in the code as default views which simply means they re available by default modules often come with views that are specific to the module data but it s also possible and highly recommended that sites which have separate development and production sites export their views into default views in a sitespecific module this makes it very easy to transfer views from dev to production without making database changes creating a module first create a directory in sites all modules for your new module call it whatever you like but for this example we will call it mymodule  in this directory create a mymodulemodule file it can be empty for now but it should at least contain an opening php tag php id it should not contain a closing tag as the closing tag is not required and anything after the closing tag such as a space or a linefeed will be displayed directly to the browser and can potentially cause problems the module file will contain functions and drupal hooks hooks are specially named functions that drupal will call in order to get your module s response at certain times while generating pages the only function you will need for this exercise is the viewsapi hook that tells views that this module supports the views api and what version function mymoduleviewsapi return array api 20 for other uses you may well add additional functions second you need to create a mymoduleinfo file id name my module description my site specific module core 6x once you have these two files set up you should be able to activate your new module at the administer site building modules page exporting your views the easiest way to do this is to activate the viewsexport module and navigate to administer views tools bulk export place a check next to each view that you want in your module type the module name into the text field and click export this will create the entire hookviewsdefaultviews  function for you you can also export individual views if you do this keep in mind that this export does not include the line that adds the exported view into the larger views array views view name view to place this into your hookviewsdefaultviews  you will need to place that after the view and make sure the function returns views at the end placing your exported views into your module cut and paste the entire output of the bulk export tool into mymoduleviewsdefaultinc and be sure to put a php at the top of the file so that the webserver knows that it s php code then visit the views tools page and clear the views cache your views should now be listed as overridden on the view list page if you revert these views they will be removed from the database but will remain in code theming your views in your module you can theme these views in the module and not need to rely on the theme to do this at all and in fact the theme can continue to override these just like it ordinarily would even if your module provides a theme this is very useful for distributing a module where the view needs to look just so to do this you need to implement hooktheme  in your module function mymoduletheme existing return array viewsviewviewnamedisplayid array arguments array view null template viewsviewviewnamedisplayid original hook viewsview path drupalgetpath module mymodule there are a small number of gotchas in doing this that you must be aware of when referring to a template filename you always use dashes in the name ie  viewsviewviewnamedisplayidtplphp  however when referring to the hook or function names you use underscores instead of dashes ie  viewsview and viewsviewviewnamedisplayid the arguments change based upon which of the 3 types you re overriding there s the display the style and the row style the above code is assuming the display which is usually just viewsview  here are the possibilities display array view null style array view null options null rows null title null row style array view null options null row null be sure to use the right arguments line or the theme system will not properly translate the template line should never include the extension so drop the tplphp from it you need to make sure that the views preprocess functions get registered the original hook line in the definition does that but it can only do it if it comes after the views registration which actually happens very late in theme building 99 of the time your module will come before views you have two choices to deal with this set your module s weight to 11 or higher in the database views weight is 10 you can make this happen automatically when the module is first installed by creating a mymoduleinstall file and using this code function mymoduleinstall dbquery update system set weight 11 where name mymodule if you use this method the original hook should be set to the name of the original template being used ie if this is a variate of viewsviewlisttplphp this should be viewsviewlist you can also just force it to list the preprocessors without actually having to detect them this doesn t require modifying your module s weight which is not always possible you can insert this code into the array preprocess functions array templatepreprocess templatepreprocessviewsview mymodulepreprocessviewsviewviewnamedisplayid the first one is the global templatepreprocess function which all templates utilize it does some basic things such as setting up zebra and a few other items see apidrupalorg for specifics the second one is the plugin specific preprocess like original hook it should conform to the name used by the original template ie if the original template was viewsviewlisttplphp then that preprocess function would be named templatepreprocessviewsviewlist  the third one is your module s preprocess function if it needs one in general you probably will not need one and you should only attempt to use one if you are reasonably familiar with the concept of preprocess functions and drupal s theme system in general see drupal s theme documentation for more information if you leave the path blank the template file will be searched for in which is the drupal install base path  