Drupal Concepts - Courses

stovenumerousInternet και Εφαρμογές Web

4 Δεκ 2013 (πριν από 3 χρόνια και 7 μήνες)

69 εμφανίσεις

Department of Computer Engineering, ChulalongkornUniversity
Atiwong Suchato
ContentManagementSystemforSocialNetworkingWebsite:DrupalHands-On
DrupalConcepts
Department of Computer Engineering, ChulalongkornUniversity
Atiwong Suchato
ContentManagementSystemforSocialNetworkingWebsite:DrupalHands-On
02
Topics
•Files & Directories Layout
•CMS and Drupal’sConcepts
Department of Computer Engineering, ChulalongkornUniversity
Atiwong Suchato
ContentManagementSystemforSocialNetworkingWebsite:DrupalHands-On
02
This Week’s Objective
•After the lecture, students should:
–Understand necessary concepts to be able to
administer a Drupalsite.
•After the completion of the assignment,
students should:
–Gain some experience on administering a
Drupalsite.
–Gain some experience on the CCK module.
–Gain some experience on the Views module.
Department of Computer Engineering, ChulalongkornUniversity
Atiwong Suchato
ContentManagementSystemforSocialNetworkingWebsite:DrupalHands-On
02
Files & Directory Layout
includes
misc
modules
profiles
sites
scripts
themes
index.php
install.php
:
:
Main entry for
Drupalinstaller
Main page for a Drupalsite
Process all “Internal Path”
Department of Computer Engineering, ChulalongkornUniversity
Atiwong Suchato
ContentManagementSystemforSocialNetworkingWebsite:DrupalHands-On
02
Files & Directory Layout
includes
misc
modules
profiles
sites
scripts
themes
Libraries of common
function that Drupaluses
Javascript, icons,
images, misc. stuffs
Core modules
(Not for 3rd-party modules)
Installation profiles
Utilities scripts
(Not used during a request)
Template engine and
default themes
(Not for additional themes)
Department of Computer Engineering, ChulalongkornUniversity
Atiwong Suchato
ContentManagementSystemforSocialNetworkingWebsite:DrupalHands-On
02
Files & Directory Layout
sites
default
all
3rd-party Modules available
to all subsites
files
themes
modules
Installation setting
Uploaded files
(Can be chosen somewhere else)
Additional themes available
to all subsites
Department of Computer Engineering, ChulalongkornUniversity
Atiwong Suchato
ContentManagementSystemforSocialNetworkingWebsite:DrupalHands-On
02
Navigating DrupalSite
•All HTTP requeststo a Drupalsite are processed
through the site’sindex.php.
•To determine a specific node or functions in Drupal, the
system interpret the internal query ?q.
http://a_drupal_site/index.php
http://a_drupal_site/index.php?q=node/43
http://a_drupal_site/index.php?q=user
http://a_drupal_site/index.php?q=admin
Front page
Front page
Content # 43
Content # 43
User page
User page
Admin page
Admin page
Department of Computer Engineering, ChulalongkornUniversity
Atiwong Suchato
ContentManagementSystemforSocialNetworkingWebsite:DrupalHands-On
02
DrupalInternal Path
http://a_drupal_site/index.php?q=XXXXXXXXX
DrupalInternal Path
http://a_drupal_site/?q=XXXXXXXXX
index.phpcan be
omitted if the web server
looks for index.phpby
default.
same as
Department of Computer Engineering, ChulalongkornUniversity
Atiwong Suchato
ContentManagementSystemforSocialNetworkingWebsite:DrupalHands-On
02
Administering Drupal
Login with a username that has
anadministrative permission.
1
User login form can
always be found at?q=user
Department of Computer Engineering, ChulalongkornUniversity
Atiwong Suchato
ContentManagementSystemforSocialNetworkingWebsite:DrupalHands-On
02
Administering Drupal
User the menu “Administer”for
entering the admin page
2
The admin page can
be found at
?q=admin
Department of Computer Engineering, ChulalongkornUniversity
Atiwong Suchato
ContentManagementSystemforSocialNetworkingWebsite:DrupalHands-On
02
Concepts in Drupal
•Nodes
–Content Types
•Taxonomy
•Menus
•Users / Permissions / Roles
•Regions / Blocks
•Theme
•Modules
Department of Computer Engineering, ChulalongkornUniversity
Atiwong Suchato
ContentManagementSystemforSocialNetworkingWebsite:DrupalHands-On
02
“Nodes”: Abstraction of Contents
•In Drupal, each “node”
is a piece of content.
node
page
story
poll
Different node type
= Different content type
Compared to OOP, different
node types can be thought of as
a subclass of the node class.
Department of Computer Engineering, ChulalongkornUniversity
Atiwong Suchato
ContentManagementSystemforSocialNetworkingWebsite:DrupalHands-On
02
“Nodes”: Abstraction of Contents
node
•Node ID (nid)
•Revision ID (vid)
•Node type
•Language and translation info
•Title of the node
•Author of the node
•Status of the node
•Created / modified date
•Comment setting
•Front page promotion / stickiness
Node Attributes
Department of Computer Engineering, ChulalongkornUniversity
Atiwong Suchato
ContentManagementSystemforSocialNetworkingWebsite:DrupalHands-On
02
Content Types
•Can be added through “module programming”or “admin
interface”
Content types from the default
installation profile
page
story
Department of Computer Engineering, ChulalongkornUniversity
Atiwong Suchato
ContentManagementSystemforSocialNetworkingWebsite:DrupalHands-On
02
Book pages are designed to be part
of a collaborative book, enabled by
the core Book module. An example
of a collaborative book is the Drupal
developer documentation. In older
versions of Drupal, only nodes of
content type Book Page could be
added to a book, but now nodes of
any content type can be part of a
book.
Other Content Types in DrupalCore
A Blog (short for weblog) is an
online journal or diary, and the
core Blog module allows
registered users on your site to
create their own blogs. Each
entry in a user blog has content
type Blog Entry.
blog entry
book page
Department of Computer Engineering, ChulalongkornUniversity
Atiwong Suchato
ContentManagementSystemforSocialNetworkingWebsite:DrupalHands-On
02
A poll is where a multiple choice
question is asked, and users can
answer and see other people's
answers to questions.
Other Content Types in DrupalCore
A Forum node defines a
topic for a forum discussion;
people can reply to the topic
by using comments. Forum
nodes are organized into
subject areas via a
Taxonomy (list of
categories).
forum
poll
Department of Computer Engineering, ChulalongkornUniversity
Atiwong Suchato
ContentManagementSystemforSocialNetworkingWebsite:DrupalHands-On
02
Creating Content
Creating a new piece of content
=
Creating a new node
Creating a new node:
?q=node/add
Accessing node w/ nid= XX:
?q=node/xx
Editing node w/ nid= XX:
?q=node/xx/edit
A new node ID (nid) will be
assigned automatically.
Department of Computer Engineering, ChulalongkornUniversity
Atiwong Suchato
ContentManagementSystemforSocialNetworkingWebsite:DrupalHands-On
02
Managing Content / Content Type
Managing Content Type
?q=admin/content/types
Managing Content
?q=admin/content/node
Add new content type, Edit/Delete existing types
List all contents, Go to content, Delete content, Change contentstatus
Department of Computer Engineering, ChulalongkornUniversity
Atiwong Suchato
ContentManagementSystemforSocialNetworkingWebsite:DrupalHands-On
02
Versioning Mechanism of Contents
nid=1
nid=1
nid=1
Content modification
Content modification
X
Department of Computer Engineering, ChulalongkornUniversity
Atiwong Suchato
ContentManagementSystemforSocialNetworkingWebsite:DrupalHands-On
02
nid=1,
vid=3
Versioning Mechanism of Contents
Content modification
New revision created
Revert back to vid= 2
X
nid=1,
vid=2
nid=1,
vid=1
Department of Computer Engineering, ChulalongkornUniversity
Atiwong Suchato
ContentManagementSystemforSocialNetworkingWebsite:DrupalHands-On
02
Nodes: Observing the database
Table:node_revisions
Table:node
Keep track of the current nodes
Primary key nid
Keep the details of all revisions of all nodes
Primary key (nid,vid)
* vidis unique among all nodes
Department of Computer Engineering, ChulalongkornUniversity
Atiwong Suchato
ContentManagementSystemforSocialNetworkingWebsite:DrupalHands-On
02
Nodes: Observing the database
Given the following actions.
Create a new page titled “About
this course”.
Create a new page titled
“Interesting Links”.
New node
nid=1, vid=1
New node
revision
nid=1, vid=1
New node
nid=2, vid=2
New node
revision
nid=2, vid=2
Table:node_revisions
Table:node
Department of Computer Engineering, ChulalongkornUniversity
Atiwong Suchato
ContentManagementSystemforSocialNetworkingWebsite:DrupalHands-On
02
Nodes: Observing the database
Given the following actions.
Edit the “Interesting Links”page
without creating a new revision.
Edit the “About this course”
page with the “create a new
revision”option checked.
No change
Content change
for the node
revision w/
nid=1, vid=1
vidof node
w/ nid=2 is
change
(from vid=2)
to vid= 3
New node
revision
nid=2, vid=3
Table:node_revisions
Table:node
Department of Computer Engineering, ChulalongkornUniversity
Atiwong Suchato
ContentManagementSystemforSocialNetworkingWebsite:DrupalHands-On
02
Nodes: Observing the database
Table:node
Table:node_revisions
Department of Computer Engineering, ChulalongkornUniversity
Atiwong Suchato
ContentManagementSystemforSocialNetworkingWebsite:DrupalHands-On
02
Nodes: Observing the database
Table:node
Table:node_revisions
Only two current nodes.
Node w/ nid= 1 has its version marked as 3
while node w/ nid= 2 has its version marked as 2
Only two current nodes.
Node w/ nid= 1 has its version marked as 3
while node w/ nid= 2 has its version marked as 2
Department of Computer Engineering, ChulalongkornUniversity
Atiwong Suchato
ContentManagementSystemforSocialNetworkingWebsite:DrupalHands-On
02
Nodes: Observing the database
Table:node_revisions
All revisions along with their details are kept in node_revisions
All revisions along with their details are kept in node_revisions
Department of Computer Engineering, ChulalongkornUniversity
Atiwong Suchato
ContentManagementSystemforSocialNetworkingWebsite:DrupalHands-On
02
Taxonomy
•Drupal’sway of classifying contents.
Dictionary
Genre
Pop
Rock
R&B
Jazz
Blue
Rap
Popularity
World-class
Well-known
So-so
Rare
Country of Origin
East Asian
Southeast Asian
Western Europe
Eastern Europe
Latin America
North America
Term
or
Tag
Department of Computer Engineering, ChulalongkornUniversity
Atiwong Suchato
ContentManagementSystemforSocialNetworkingWebsite:DrupalHands-On
02
Taxonomy
Ra
p
S
o
-
s
o
N
o
r
t
h

A
m
e
r
i
c
a
Terms in each dictionary can
be attached toa node of the
desired content type in order for
classification based on terms in
these dictionary.
Single / Multiple tagging
On-the-fly tagging
Optional / Required
Department of Computer Engineering, ChulalongkornUniversity
Atiwong Suchato
ContentManagementSystemforSocialNetworkingWebsite:DrupalHands-On
02
Menus
Drupalmenus provide
•links to content
•callbacks to functions (in a
module)
Drupalmenus can be
organized into a hierarchical
structure (nested menus).
Visibilities of each menu item
can be controlled based on
user’s permissions.
Menu
Menu item
Department of Computer Engineering, ChulalongkornUniversity
Atiwong Suchato
ContentManagementSystemforSocialNetworkingWebsite:DrupalHands-On
02
Menus
About
Products
Offices
Committees
Laptops
Desktops
Peripherals
Printers
Scanners
Manage at:
?q=admin/build/menu
Department of Computer Engineering, ChulalongkornUniversity
Atiwong Suchato
ContentManagementSystemforSocialNetworkingWebsite:DrupalHands-On
02
Menus
•There are 3 standard menus in Drupal.
Primary Links
Secondary Links
Navigation
Administration links
Navigating site contents
Department of Computer Engineering, ChulalongkornUniversity
Atiwong Suchato
ContentManagementSystemforSocialNetworkingWebsite:DrupalHands-On
02
Users, Permissions, Roles
“Users are the reason
for using Drupal!”
Vandyk, Pro DrupalDevelopment, APress
Department of Computer Engineering, ChulalongkornUniversity
Atiwong Suchato
ContentManagementSystemforSocialNetworkingWebsite:DrupalHands-On
02
Users, Permissions, Roles
Anonymous User
Authenticated User
Administrator
Content Editor
Proof Reader





Roles
Permissions
A user can have one
or more roles.
Permissions are
defined for each role.
Department of Computer Engineering, ChulalongkornUniversity
Atiwong Suchato
ContentManagementSystemforSocialNetworkingWebsite:DrupalHands-On
02
Users, Permissions, Roles
Administrator
Proof Reader
AB
Proof Reader + Administrator
A∪B
Department of Computer Engineering, ChulalongkornUniversity
Atiwong Suchato
ContentManagementSystemforSocialNetworkingWebsite:DrupalHands-On
02
Users, Permissions, Roles
User management can
be found at:
?q=admin/user
Access rules
List and create rules to disallow usernames, e-mail addresses,
and IP addresses.
Permissions
Determineaccesstofeaturesbyselectingpermissionsforroles.
Roles
List, edit, or add user roles.
Usersettings
Configuredefaultbehaviorofusers,includingregistration
requirements,e-mails,anduserpictures.
Users
List, add, and edit users.
Department of Computer Engineering, ChulalongkornUniversity
Atiwong Suchato
ContentManagementSystemforSocialNetworkingWebsite:DrupalHands-On
02
Access Rules
Department of Computer Engineering, ChulalongkornUniversity
Atiwong Suchato
ContentManagementSystemforSocialNetworkingWebsite:DrupalHands-On
02
Roles Administration
?q=admin/user/roles
Built-in roles
Any users who are not logged in has the role of an
“anonymous user”by default.
Any users who are logged in has a role of an “authenticated
user”by default.
Department of Computer Engineering, ChulalongkornUniversity
Atiwong Suchato
ContentManagementSystemforSocialNetworkingWebsite:DrupalHands-On
02
Permissions Administration
?q=admin/user/permissions
Department of Computer Engineering, ChulalongkornUniversity
Atiwong Suchato
ContentManagementSystemforSocialNetworkingWebsite:DrupalHands-On
02
Users Administration
?q=admin/user/user
Department of Computer Engineering, ChulalongkornUniversity
Atiwong Suchato
ContentManagementSystemforSocialNetworkingWebsite:DrupalHands-On
02
Users: Observing the database
Table:users
Table:users_roles
Table:role
Table:permissions
Listing all users.
Primary key uid
Listing all roles.
Primary key rid
Listing all
permission set.
Primary key pid
Listing all user-role
mapping.
Primary key 
(uid,rid)
All anonymous user accessing the site is thought of as the
user w/ uid= 0.
The user logging in with the admin account created during
installation of the site is assigned with uid= 1.
Department of Computer Engineering, ChulalongkornUniversity
Atiwong Suchato
ContentManagementSystemforSocialNetworkingWebsite:DrupalHands-On
02
Users: Observing the database
Given the following scenario:
Available roles:
instructor
registered student
teaching assistant
site tester
Department of Computer Engineering, ChulalongkornUniversity
Atiwong Suchato
ContentManagementSystemforSocialNetworkingWebsite:DrupalHands-On
02
Users: Observing the database
Given the following scenario (cont.):
admin
uid= 1
Created
during the
site’s
installation
atiwong
uid= 2
Role:
Instructor +
Site Tester
supadaech
uid= 3
Role:
Teaching
assistant +
Site Tester
student01
uid= 4
Role:
Registered
student
Department of Computer Engineering, ChulalongkornUniversity
Atiwong Suchato
ContentManagementSystemforSocialNetworkingWebsite:DrupalHands-On
02
Users: Observing the database
Table:users
* Not all fields are shown.
Table:role
Table:users_roles
Department of Computer Engineering, ChulalongkornUniversity
Atiwong Suchato
ContentManagementSystemforSocialNetworkingWebsite:DrupalHands-On
02
Users: Observing the database
Table:permissions
Permissions are stored as text strings.
Drupalprovides built-in functions that can process these
permission text strings.
Department of Computer Engineering, ChulalongkornUniversity
Atiwong Suchato
ContentManagementSystemforSocialNetworkingWebsite:DrupalHands-On
02
Templates, Regions, Blocks
Each page’s presentation in a
Drupalwebsite is governed by
“templates”where “regions”
are defined.
header
footer
main
content
Left sidebar
Right sidebar
Regions
Department of Computer Engineering, ChulalongkornUniversity
Atiwong Suchato
ContentManagementSystemforSocialNetworkingWebsite:DrupalHands-On
02
Templates, Regions, Blocks
“Blocks”are chunks of info that are to be displayed in the
regions.
Block#1
Block#2
Block#3
A block could be:
a menu.
supplied by a module.
provided explicitly
through the admin
interface using static
contents or dynamic
scripts.
Department of Computer Engineering, ChulalongkornUniversity
Atiwong Suchato
ContentManagementSystemforSocialNetworkingWebsite:DrupalHands-On
02
header
footer
main
content
Left sidebar
Right sidebar
Templates, Regions, Blocks
Block#1
Block#2
Block#3
Blocks are made visible by
being put into a region of the
template.
?q=admin/build/block
Department of Computer Engineering, ChulalongkornUniversity
Atiwong Suchato
ContentManagementSystemforSocialNetworkingWebsite:DrupalHands-On
02
Themes
•Themes control the presentation of Drupalwebsites.
–Graphics look
–Layout (Regions)
–Colors
Themeinga
Drupalwebsite
usually requires:
PHP
CSS
One or more PHP
file governing the
HTML output of a
page
One ore more
Stylesheetdefining
fonts, colors, and
other styles
Department of Computer Engineering, ChulalongkornUniversity
Atiwong Suchato
ContentManagementSystemforSocialNetworkingWebsite:DrupalHands-On
02
Themes
?q=admin/build/themes
Department of Computer Engineering, ChulalongkornUniversity
Atiwong Suchato
ContentManagementSystemforSocialNetworkingWebsite:DrupalHands-On
02
Installing New Themes
1.Put the theme files under sites/all/themes
2.Enable it through ?q=admin/build/themes
Department of Computer Engineering, ChulalongkornUniversity
Atiwong Suchato
ContentManagementSystemforSocialNetworkingWebsite:DrupalHands-On
02
Modules
•Pieces of code extending Drupal’sfunctionalities.
Core Modules
Contributed
Modules
Module Development
Shipped with Drupal
Can be enabled
Download then enable
Download
Contribute
DrupalCommunity
Department of Computer Engineering, ChulalongkornUniversity
Atiwong Suchato
ContentManagementSystemforSocialNetworkingWebsite:DrupalHands-On
02
Module Installation
1.Place the module code in
sites/all/modules
2.Enable the module at:
?q=admin/build/modules
Otherwise specify by the
module’s documentation
Department of Computer Engineering, ChulalongkornUniversity
Atiwong Suchato
ContentManagementSystemforSocialNetworkingWebsite:DrupalHands-On
02
Developing a Module
•Understanding of the Drupalframework
•PHP Programming
•Database Querying
•DrupalAPI