Professional Documents
Culture Documents
hook_views_api()
The first thing you have to do is tell Views that your module is going to using the Views API
hook_views_api()
Next we creating new file with name: mymodule.views.inc and it should be placed in our current module: includes/views/
This line tells views to look in /includes/views/ and all hooks from this file will be auto-loaded by views module.
hook_views_api()
hook_views_api()
You can use here all hooks provided by views core module.
http://api.drupal.org/api/views/views.api.php/
If you want to send an argument into the views contextual filter, simply add another argument to the views_embed_view function.
Here can be any other argument, nid, title, date for example: if you use a date as a contextual filter the allowed type of format date is YYYY-MM-DD.
Small Tip
Why we should to rename views display machine name ?
Small Tip
Will help you with naming views template files Help developers when using views programmatically Help site maintainers to maintain a view with multiple displays Help themer to easy theme the view
views_get_view()
Get a view from the database or from default views. This function is just a static wrapper around views::load(). This function isn't called 'views_load()' primarily because it might get a view from the default views which aren't technically loaded from the database.
Filtering Results
Lets add a filter and filtering rows based on the $delta value. Views prefers the date in a machine readable format, according to the UI.
hook_views_query_alter()
variables from exposed filters in query or join new table to the views query.
hook_views_query_alter()
hook_views_pre_view()
Allows altering a view at the very beginning of views processing, before anything is done. You can change here view $display_id or override view arguments.
hook_views_pre_view()
Small example:
hook_views_pre_render()
This hook is called right before the render process. The query has been executed, and the pre_render() phase has already happened for handlers, so all data should be available.
hook_views_pre_render()
hook_views_default_views()
This hook allows modules to provide their own views which can either be used as-is or as a "starter" for users to build from.This hook should be placed in MODULENAME.views_default.inc
hook_views_default_views()
You just need to add your exported view here and it will be used as default.
Questions ?
Thanks you
sorin.dediu@wearepropeople.com