18.10.2016 Views

Drupal 7 Module Development

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Table of Contents<br />

Using hook_node_access() 254<br />

A sample access control module 254<br />

A second access control module 256<br />

View operations and access control modules 259<br />

When to write a node access module 260<br />

The {node_access} table and its role 261<br />

{node_access} table schema explained 263<br />

Defining your module's access rules 264<br />

Creating the role access module 266<br />

Using hook_node_access_records() 266<br />

Using hook_node_grants() 269<br />

Security considerations 271<br />

Rebuilding the {node_access} table 273<br />

Modifying the behavior of other modules 274<br />

Using hook_node_grants_alter() 275<br />

Using hook_node_access_records_alter() 279<br />

Testing and debugging your module 282<br />

Using Devel Node Access 282<br />

Using hook_node_access_explain() 283<br />

Using the Devel Node Access by user block 284<br />

Summary 285<br />

Chapter 10: JavaScript in <strong>Drupal</strong> 287<br />

JavaScript inside <strong>Drupal</strong> 287<br />

Adding JavaScript 288<br />

Adding JavaScript and CSS files to .info files 289<br />

Using drupal_add_js() 289<br />

Adding JavaScript files 289<br />

Adding CSS files 292<br />

Passing variables from PHP to JavaScript 293<br />

Adding inline JavaScript 294<br />

Adding inline CSS 294<br />

Using the Library API 295<br />

Defining a library with hook_library 296<br />

Altering information in hook_library 297<br />

Using renderable arrays 298<br />

Altering JavaScript 299<br />

Altering CSS 300<br />

<strong>Drupal</strong> specific JavaScript 301<br />

Themeable presentation 301<br />

Translatable strings 302<br />

Behaviors 303<br />

[ vi ]

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!