Info

Our Target Module: What We Want 91 Creating a Custom Content Type 92

Using the Administration Interface to Create a Content Type 93 Content and Nodes 97 The Foundations of the Module 97 A Simple Database Lookup 100 Getting the Node ID 100

Getting the Node's Content 102

Theming Inside a Module 103

Registering a Theme 105

Creating a Theme Hook Function 108

Adding a Stylesheet 109

Overriding the Default Theme from a Theme 111

A Quick Clarification 111

Overriding the Default Theme's CSS 112

Overriding Layout with Templates 113

Summary 114

Chapter 5: Using JavaScript and AJAX/JSON in Modules_115

Picking up Where We Left Off 115

Introducing jQuery 117

Modifying HTML with jQuery 118

Checking for JavaScript Support with Drupal 121

Namespaces in JavaScript 121

Drupal's Namespace 121

A Drupal Function: Drupal.jsEnabled() 122

Delaying JavaScript Execution with jQuery 123

Including JavaScript from the Module's Theme 124

Writing a Drupal AJAX/JSON Service 127

The JSON Format 127

Our Module Roadmap 129

Server Side: Defining a New Page 129

Creating a JSON Message 129

Mapping a Function to a URL 131

Passing PHP Settings to JavaScript 135

Client Side: AJAX Handlers 137

A JavaScript Function to Get JSON Content 137

Adding an Event Handler 140

Summary 141

Chapter 6: An Administration Module_143

The emailusers Module 143

The Beginning of the Module 144

Mail Configuration 145

Registering an Administration Page 146

A Detailed Look at the Path 147

Marking the Path as an Administration Page 147

Path Registration Parameters 148

Defining the Callback Function 151

Handling Forms with the Forms API (FAPI) 153

Loading a Form with drupal_get_form() 154

A Form Constructor 154

Handling Form Results 161

The Form Submissions Callback 162

Sending Mail with the Mail API 165

Formatting Mail with hook_mail() 167

Altering Messages with hook_mail_alter() 172

Altering Hooks 172

Adding a Mail Footer 173

Incorporating the Module into Administration 175

Modifying the User Profile with hook_user() 176

Constructing the Content 178

Summary 180

Chapter 7: Building a Content Type_181

The biography Module 181

The Content Creation Kit 182

The Starting Point 183

The Module Installation Script 184

The Schema API: Defining Database Structures 186

A First Look at the Table Definition 187

Defining Fields (Columns) 188

Defining Keys and Indexes 190

Correlating the New Table with Nodes 192

The Content Creation Form 196

Overriding hook_form() Defaults 198

Adding New hook_form() Form Elements 199

Access Controls 202

Database Hooks 205

Database Inserts with hook_insert() 205

Updating and Deleting Database Records 209

Hooks for Getting Data 211

Loading a Node with hook_load() 212

Preparing the Node for Display with hook_view() 214

Theming Biography Content 217

Registering a Theme 217

The biography_info.tpl.php Template 219

The Results 220

Summary 221

Chapter 8: Filters, Actions, and Hooks_223

The sitenews Module 224

Getting Started 225

Citing Dependencies in the .info File 225

The Beginning of the .module File 227

A Simple Content Type, Defined in Code 228

Creating Filters and an Input Format 230

The Second Filter: Remove All Tags 239

Adding an Input Format 241

The Beginning of an Action 247

Implementing hook_action_info() 247

The Action Callback 250

Defining a Hook 253

Invoking a Custom Hook 254

So What Is a Hook? 255

Creating a hook_sitenews() Function 255

Implementing hook_sitenews() in Other Modules 257

In the philquotes Module 257

In the biography Module 258

Completing the Action: Theming and Mailing 261

Theme Functions 265

The hook_mail() Implementation 267

Adding a Trigger 269

Summary 272

Chapter 9: An Installation Profile_273

Introducing Installation Profiles 273

Why Use Installation Profiles? 274

Setting up a Distribution 276

Creating a Profile Directory 277

Programming Profiles 278

The .profile Script 279

The Details Function 279

The Modules List 281

The Installation Task System 282

The Profile Task 283

A Basic Profile Task 283

A Complex Profile Task 285

Moving to the Next Task 290

Registering a New Task 291

The Theme Selection Form 292

Returning to the philosopherbios_pick_theme Task 294

The Submission Handler 295

Finishing the Installation Profile 300

Packaging the Distribution 302

Summary 302

Index_303

0 0

Post a comment