Siêu thị PDFTải ngay đi em, trời tối mất

Thư viện tri thức trực tuyến

Kho tài liệu với 50,000+ tài liệu học thuật

© 2023 Siêu thị PDF - Kho tài liệu học thuật hàng đầu Việt Nam

Drupal
PREMIUM
Số trang
279
Kích thước
6.6 MB
Định dạng
PDF
Lượt xem
1426

Drupal

Nội dung xem thử

Mô tả chi tiết

Drupal

Creating Blogs, Forums, Portals, and

Community Websites

How to set up, configure, and customize this powerful

PHP/MySQL-based Open Source CMS

David Mercer

BIRMINGHAM - MUMBAI

Drupal

Creating Blogs, Forums, Portals, and Community Websites

2006 Packt Publishing

Every effort has been made in the preparation of this book to ensure the accuracy of the

information presented. However, the information contained in this book is sold without warranty,

either express or implied. Neither the author, Packt Publishing, nor its dealers or distributors will

be held liable for any damages caused or alleged to be caused directly or indirectly by this book.

Packt Publishing has endeavored to provide trademark information about all the companies and

products mentioned in this book by the appropriate use of capitals. However, Packt Publishing

cannot guarantee the accuracy of this information.

First published: May 2006

Production Reference: 1040506

Published by Packt Publishing Ltd.

32 Lincoln Road

Olton

Birmingham, B27 6PA, UK.

ISBN 1-904811-80-9

www.packtpub.com

Cover Design by www.visionwt.com

Credits

Author

David Mercer

Reviewers

Jason Flatt

Kobus Myburgh

Technical Editors

Niranjan Jahagirdar

Maria Menezes

Editorial Manager

Dipali Chittar

Development Editor

Louay Fatoohi

Indexer

Mithil Kulkarni

Proofreader

Chris Smith

Production Coordinator

Manjiri Nadkarni

Cover Designer

Helen Wood

About the Author

David Mercer was born in August 1976 in Harare, Zimbabwe. Having always had a strong

interest in science, David came into regular contact with computers at university where he

minored in computer science.

A programmer and professional writer who has been writing both code and books for about seven

years, he has worked on a number of well known titles, in various capacities, on a wide variety of

topics. This has afforded him a singularly unique oversight into the world of programming and

technology as it relates to furthering the goals of business.

David finds that the challenges arising from the dichotomous relationship between the science

(and art) of software programming and the art (and science) of writing is what keeps his interest in

producing books piqued. He intends to continue to write professionally in the future.

David balances his time between programming, reviewing, writing, and furthering his studies

in Applied Mathematics. When he isn't working (which isn't that often) he enjoys playing

guitar and getting involved in outdoor activities ranging from touch rugby and golf to water

skiing and snowboarding.

Visit www.contechst.com for an overview of articles, books, and other projects by David.

A big thanks to the team at Packt for giving me the opportunity to work on this book.

Thanks to the excellent contributions made by the reviewers as well as my family and

friends who have supported and encouraged me over the last six months or so.

"Ad astra per aspera."

About the Reviewers

Jason Flatt is a computer solutions provider, specializing in Linux systems and Drupal websites,

living in his hometown of Las Vegas, NV with his wife and five sons. Jason can be contacted at

[email protected].

Kobus Myburgh is an IT consultant, working at a large university in South Africa, focusing

on IT innovations particularly useful to the students of the university, as well as keeping the

student IT facilities in mint condition, including software, hardware, as well as network and

internet connectivity.

Kobus obtained his Honors B. Sc. degree in IT at the same university and is also a part-time

lecturer, currently teaching third-year students about Expert Systems, with a strong focus on this

sub-section of Artificial Intelligence.

He also has extensive knowledge and experience in web design and development, particularly in

PHP, HTML, and CSS, and has been involved with the Drupal project since its inception in 2001.

Table of Contents

Preface 1

Chapter 1: Introduction to Drupal 5

Drupal—An Overview 6

How Drupal Came to Be 7

What Drupal Has to Offer 8

Uses of Drupal 9

Building a Drupal Site 10

Planning Your Site 11

Analyzing the Proposed Solution 12

Feasibility 12

Phone a Friend 12

Critical versus Desirable Criteria 13

The Demo Website 13

The Drupal Community 16

Support 17

Handbooks 20

Forum 21

Downloads 24

Contribute 26

Contact and Community 27

The Drupal License 28

Summary 30

Chapter 2: Setting Up the Development Environment 31

The Drupal Environment 32

Obtaining and Installing PHP, Apache, and MySQL 34

Obtaining and Installing Drupal 37

Upgrading Drupal 41

Troubleshooting Common Problems 44

A Short Tour of Drupal 46

A Couple of Important Settings 46

Creating an Administrative User 47

Table of Contents

Using the Administrative Panel 49

A Sample Drupal Page 51

Summary 53

Chapter 3: Basics I: Site Configuration 55

Before We Start 56

General Settings 58

Error Handling 62

Cache and File System Settings 66

RSS Feed Settings 68

Date Settings 68

Site Maintenance 69

String Handling 70

Summary 70

Chapter 4: Basics II: Adding Functionality 71

Adding Modules 72

Third-Party Modules 72

Downloading Modules 73

Installing Modules 74

Configuring Modules 75

Forum 75

Locale 78

Comments 79

Content Types 82

Search 84

Upload 84

Menus and Primary Links 85

Using Modules 90

Working with Blocks 92

Adding Blocks 93

Configuring Blocks 95

Summary 97

Chapter 5: Users, Roles, and Permissions 99

Planning an Access Policy 100

Roles 101

ii

Table of Contents

Permissions 102

Setting Permissions with Taxonomy Access Control 105

Users 110

Administering Users 110

Configuring Users 111

Access Rules 114

Summary 117

Chapter 6: Basic Content 119

Content Types 119

Working with Content 122

Content Options 122

Administering Content 127

Content-Related Modules 130

Aggregator 130

Archive 140

Similar Entries 140

Taxonomy Block 143

Summary 145

Chapter 7: Advanced Content 147

HTML, PHP, and Content Posting 148

Input Formats and Filters 148

HTML 154

Creating a Feature-Rich Page 156

Posting a Feature-Rich Page 162

Categorization 164

What and Why? 164

Implementing Taxonomies in Drupal 166

Introduction to Vocabularies 166

Dealing with Descriptors 168

Posting Content with Categories Enabled 169

Hierarchies 170

Content Structure 171

Summary 176

iii

Table of Contents

Chapter 8: Drupal's Interface 177

Planning a Web-Based Interface 178

Visual Design 178

Language 179

Images 179

How Drupal's Interface Works 181

CSS 183

Themes 184

Choosing a Base Theme 184

Configuring Your Themes 188

Customizing Your Theme 191

Images 194

Colors 198

Page Modifications 200

Summary 202

Chapter 9: Advanced Features and Modifications 203

Flexinode 204

Downloading and Installing Flexinode 204

Creating a Custom Content Type 206

Adding Structure 208

AdSense 209

Installing and Configuring AdSense 209

Adding Google Ads to Your Pages 216

Adding Google Ads to Your Content 220

Advanced Site Modifications 222

Scrolling News Ticker 223

Obtaining the Ticker 224

Creating the Content 225

Dynamic Content Page 226

Incorporating the Application into the Theme 226

Building the Content Page 228

Summary 232

Chapter 10: Running Your Website 233

Backups 234

phpMyAdmin 234

The mysqldump Utility 236

iv

Table of Contents

Cron and Scheduled Tasks 237

The Crontab 237

Windows Scheduled Tasks 238

Poormanscron 239

Throttling 241

Patching 243

Website Activities 246

Search Engine Optimization 247

Maintaining Users 249

Summary 250

Appendix A: Deployment 251

Getting Ready to Deploy 251

Make Sure the Host Is Ready 252

Get the Files Ready 253

Get the Database Ready 254

Transfer the Files 255

Setting Up the Site 255

Set Up the Files 256

Set Up the Database 257

Configure the Site 258

Access Problem? 258

Testing 259

Summary 261

Index 263

v

Preface

The Internet is arguably one of the most profound achievements in human history. It has become

so pervasive in our lives that we hardly even notice it—except when it happens to be unavailable!

It's one of those things that make you sit back and wonder how people got along without it in the

old days. Without the ability to surf the Internet to order groceries, do our banking, book flights

and make travel arrangements, meet friends, meet partners, download music and videos, study, run

businesses, trade shares, run campaigns, express views, share ideas, learn about other people…

where would we be?

Fundamentally, in a world of so many people, where the sheer vastness of our societies is a

hindrance to communication, the Internet has stepped up to the plate and brought everyone that

little bit closer together. Utilizing a stunning array of technologies, spread out over the entire

globe, the Internet has simply dropped the barriers of time and geographical distance to turn the

entire world into a local community center.

Lately, the all-encompassing focus of commerce on the Internet has begun to shift slightly.

Millions upon millions of people are waking up to the possibility of sharing their lives and

experiences with others through the medium of weblogs (blogs for short). Others simply want an

online presence to show off their work, art, or music. Still others have important causes and need

the Internet to disseminate information or provide a meeting point for like-minded people.

Whatever the demands, the Internet has to find a way to efficiently meet these needs or face being

superseded by something else in the future.

What the Internet needs is something that makes it easy for people to do whatever it is they want

without having to pour intellectual resources into understanding the technologies on which the

Internet is based. What the Internet has got is precisely this—Drupal!

Drupal is what you need to use to build anything from a static homepage, to a fully-fledged,

customizable, and interactive website in several languages, with tens of thousands of users all over

the world. Assuming you fall somewhere between these two extremes, this book is what you need

to guide you on your way.

This book will help cut down your learning time by providing precisely the information you need

when you need it. It will help to reduce the trial and error associated with learning any new

technology and provide you with a methodical and efficient learning process so that you become a

knowledgeable and competent website creator and administrator.

Preface

2

What This Book Covers

Chapter 1 introduces you to the world of Drupal and looks at where Drupal comes from, where it's

going, and what it can offer you. Because it is important to understand the nature of the tasks that

lie ahead, it also discusses how to plan and build your website, taking a sneak preview of the

book's demo website in the process. Finally, we scrutinize the Drupal community and learn how to

make the most of Drupal as an organized, living entity and not just a piece of software.

Chapter 2 deals with how to get everything you need up and running on a development machine

and also briefly looks at how all the requisite technologies gel together to produce your working

Drupal site. Once everything is up and running, and after looking over some of the more common

installation problems, the chapter presents a short tour of Drupal in order to give you an idea of

what to expect.

Chapter 3 looks at the most general settings that all Drupal administrators need to contend with.

Everything from determining your site's name to dealing with the cache or file system settings gets

treated here before we look at more focused and complex issues in the chapters to come.

Chapter 4 sees us adding functionality to the newly created site. The focus of this chapter is really

on modules and how they can be added and enabled, and also how to obtain modules that are not

part of the standard distribution. This chapter ends off with a discussion on how to control blocks.

Chapter 5 concerns itself with the topic of access control. Drupal has a sophisticated role-based

access control system, which is fundamentally important for controlling how users access your

site. This chapter will give you the information you need to implement whatever access controls

you require.

Chapter 6 gets to the heart of the matter by beginning the book's coverage on content. Working

with content, what content types are available, administering content, and even a discourse on

some of the more common content-related modules serve as a basis for moving to more advanced

content-related matters that follow in the next chapter.

Chapter 7 gives you the edge when it comes to creating engaging and dynamic content. While this

chapter doesn't require you to be an expert in HTML, PHP, and CSS, it does introduce you to the

basics and shows how, with a little knowledge, extremely powerful and professional content can

be created. That's only half the story, because later on it looks at categorization and how this

particular feature of Drupal sets it apart from everything else out there.

Chapter 8 gives you a run down of how attractive interfaces are created in Drupal through the use

of themes. As well as discussing briefly some of the considerations that must be taken into account

when planning your website, it ends off by looking at how to make important modifications to

your chosen theme.

Chapter 9 really adds the icing on the cake by looking at a host of more advanced topics. From

creating flexible content types and generating revenue from ads, all the way through to building

dynamic content using AJAX, you will find something to enhance your website and add that

something special.

Preface

Chapter 10 takes a pragmatic look at the types of tasks you will need to be proficient in so as to

successfully run and maintain a Drupal site. Whether it's setting up cron jobs or making backups

of your database, everything you need to do throughout the course of running your newly created

website will be covered here.

Appendix A deals with the all-important topic of deployment. Because all major work should be

done on a copy of your website on a development machine, this appendix presents a sound process

for taking the finished product and making it available for public consumption on your host site.

Conventions

In this book, you will find a number of styles of text that distinguish between different kinds of

information. Here are some examples of these styles, and an explanation of their meaning.

There are three styles for code. Code words in text are shown as follows: "We can include other

contexts through the use of the include directive."

A block of code will be set as follows:

<?php

if (module_exist("adsense"))

{

print adsense_display("468x60", 2);

}

?>

When we wish to draw your attention to a particular part of a code block, the relevant lines or

items will be made bold:

<?php

if (module_exist("adsense"))

{

print adsense_display("468x60", 2);

}

?>

Any command-line input and output is written as follows:

$ mysql –uroot -p drupal < C:\apache2triad\htdocs\drupal\modules\

taxonomy_block\taxonomy_block.mysql

New terms and important words are introduced in a bold-type font. Words that you see on the

screen, in menus or dialog boxes for example, appear in our text like this: "clicking the Next

button moves you to the next screen".

Warnings or important notes appear in a box like this.

Tips and tricks appear like this.

3

Tải ngay đi em, còn do dự, trời tối mất!