-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial commit upload of working module
- Loading branch information
Showing
5 changed files
with
99 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,22 @@ | ||
views_in_code | ||
============= | ||
|
||
A boilerplate module for keeping your Drupal views safely in code. The benefits are safety and a performance boost. | ||
A boilerplate module for keeping your Drupal views safely in code. The benefits are safety and a slight performance advantage. | ||
|
||
USAGE | ||
===== | ||
|
||
See the included example view to get an idea of what the exported view should look like | ||
|
||
1) Paste the exported view into an empty file below a php opening tag and save with the .views extension. | ||
|
||
2) save your views in the views_in_code/views directory. | ||
|
||
3) Upload to your modules directory (ie: /sites/all/modules) and enable | ||
|
||
4) Your views in code should show up in the views listings | ||
|
||
5) If you modify a view that you have in code, export it and overwrite the existing view in code. Once you upload the updated version, clear all caches and then revert the view. This will clear the view and your new code will take precedence. | ||
|
||
NOTE | ||
This is a Drupal 7 + Views 3.0 module. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
$view = new view(); | ||
$view->name = 'example_view'; | ||
$view->description = 'Example View for the Views in Code module'; | ||
$view->tag = 'default'; | ||
$view->base_table = 'node'; | ||
$view->human_name = 'Example View'; | ||
$view->core = 7; | ||
$view->api_version = '3.0'; | ||
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */ | ||
|
||
/* Display: Master */ | ||
$handler = $view->new_display('default', 'Master', 'default'); | ||
$handler->display->display_options['title'] = 'Example View'; | ||
$handler->display->display_options['use_more_always'] = FALSE; | ||
$handler->display->display_options['access']['type'] = 'perm'; | ||
$handler->display->display_options['cache']['type'] = 'none'; | ||
$handler->display->display_options['query']['type'] = 'views_query'; | ||
$handler->display->display_options['exposed_form']['type'] = 'basic'; | ||
$handler->display->display_options['pager']['type'] = 'full'; | ||
$handler->display->display_options['pager']['options']['items_per_page'] = '10'; | ||
$handler->display->display_options['style_plugin'] = 'default'; | ||
$handler->display->display_options['row_plugin'] = 'node'; | ||
/* Field: Content: Title */ | ||
$handler->display->display_options['fields']['title']['id'] = 'title'; | ||
$handler->display->display_options['fields']['title']['table'] = 'node'; | ||
$handler->display->display_options['fields']['title']['field'] = 'title'; | ||
$handler->display->display_options['fields']['title']['label'] = ''; | ||
$handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE; | ||
$handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE; | ||
/* Sort criterion: Content: Post date */ | ||
$handler->display->display_options['sorts']['created']['id'] = 'created'; | ||
$handler->display->display_options['sorts']['created']['table'] = 'node'; | ||
$handler->display->display_options['sorts']['created']['field'] = 'created'; | ||
$handler->display->display_options['sorts']['created']['order'] = 'DESC'; | ||
/* Filter criterion: Content: Published */ | ||
$handler->display->display_options['filters']['status']['id'] = 'status'; | ||
$handler->display->display_options['filters']['status']['table'] = 'node'; | ||
$handler->display->display_options['filters']['status']['field'] = 'status'; | ||
$handler->display->display_options['filters']['status']['value'] = 1; | ||
$handler->display->display_options['filters']['status']['group'] = 1; | ||
$handler->display->display_options['filters']['status']['expose']['operator'] = FALSE; | ||
|
||
/* Display: Page */ | ||
$handler = $view->new_display('page', 'Page', 'page'); | ||
$handler->display->display_options['path'] = 'example-view'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
/** | ||
* Implementation of hook_views_default_views(). | ||
**/ | ||
function views_in_code_views_default_views() { | ||
$files = file_scan_directory(drupal_get_path('module', 'views_in_code'). '/views', '/.*\.view$/'); | ||
foreach ($files as $filepath => $file) { | ||
require $filepath; | ||
if (isset($view)) { | ||
$views[$view->name] = $view; | ||
} | ||
} | ||
return $views; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
name = "Views in Code" | ||
description = "Code Repository for Views used in the site. Place views code in: /sites/all/modules/views_in_code/views" | ||
package = Views | ||
core = 7.x | ||
version = "7.x-1.0" | ||
dependencies[] = views | ||
files[] = views_in_code.module |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
/** | ||
* Implements hook_views_api(). | ||
*/ | ||
function views_in_code_views_api() { | ||
return array( | ||
'api' => 3, | ||
'path' => drupal_get_path('module', 'views_in_code') . '/views', | ||
); | ||
} |