With Drupal
Presented By Mathew Winstone
uOttawa-WPA
user: uo-guest3313
password: 60ntb6bj!
uOttawa-WPA
user: uo-guest542
password: 0ocvx1td!
My name is Mathew Winstone, CEO of Coldfront Labs Inc. I build Drupal web applications for a living.
I've been building stuff with Drupal for about 9 years.
Building the single greatest task manager you've ever used!
Or at least the best one you can build in a day.
Go to getpantheon.com and create your account.
Select a name for your site.
(ex: my-awesome-site)
Your site name has to be unique though.
Choose Drupal 7 as your site install type.
Then visit your site to install it.
Choose "Standard" install.
Fill in all the required fields as necessary.
Yes there's a spelling mistake...
Use the Admin Toolbar at the top of the page.
Click on "Content", then "Add Content", then "Add Article".
Let's see if our tasks work well as articles.
Default container for storing content in Drupal.
You can add your own content types to fit your needs.
Add a "Task" content type.
Click on "Structure" then "Content Types"
Here you can see the current list of content types.
Add one called "Task"
Don't forget to set your publishing options,
and your comment settings,
and turn off menus (we'll deal with this later).
Content types are made up of "fields". Fields are what make one content type unique compared to one another.
When you create a new content type you get the "Title" and "Body" fields by default.
Let's customize the "Body" field settings.
Field settings are broken into two parts; instance settings and global settings.
Instance settings are the settings specific to this field and this content type.
Changing those settings only affect this field on this content type.
Global field settings affect the field on every content type they're used.
For example, "Article" and "Task" types both use the "Body" field.
If you change the settings in "Task", you'll change the settings for "Article" as well.
Be careful changing global settings.
Of all the things you do with Drupal, you'll more than likely spend your time adding / customizing / removing fields. Be sure you grasp how they work.
It's important.
Everything else we do today will use these fields in one way or another.
Click on "Content" then "Add Content". You'll see the "Add Task" option. Fill in the form.
A "Field Type" defines the kind of information you want to store in the field. Drupal has field types for:
A "Field Widget" is the tool which users will use to enter this data.
For example, if you have a list of stuff, you can use the "select list" widget.
Different field types have different widget options.
Since we're storing a list of text values, we'll use the "List (text)" field type.
Users can use the "Select list" widget to make their selection.
Other options include radio buttons and checkboxes.
Name your field "Status".
When you add a new field, you'll always setup the "global" field settings first.
Use the options below as your "Allowed values list"
active|Active
complete|Complete
Next we configure the settings specific to this field on this content type.
Set your help text, default value and required settings.
Similar to how fields let you customize content types, modules let you customize Drupal itself.
They can do anything!
Modules are what make Drupal great for a lot of different uses.
Adding options to our select list was kind of ugly.
Options element module makes it nicer!
Let's download / install the module.
https://www.drupal.org/project/options_element
Themes, modules and install profiles are all different kinds of projects on Drupal.org.
Each of them let you customize Drupal in a different way.
A "release" is a particular version of that project. Typically you want to stick with "Recommended" releases (the green ones).
If you want the bleeding edge, you can use dev releases. But be warned, these can break your site...
Adding new modules to your site has three steps.
Normally, you put them in "sites/all/modules" on the server.
Pantheon let's you upload them through the UI and puts them in place automatically!
Click on the "Modules" option in the admin toolbar.
Click on "Install new module"
Copy the link from Drupal.org for your release and paste it into the box.
Click "Install"
While we're here, let's add a module to make managing modules better! (whoa...)
Google "drupal module filter"
Find the recommended release link and add the module to your site.
Click enable and configure.
Find the "Module Filter" module in the list on the page (use CTRL-F or CMD-F)
Check the box next to it.
Click "Save Configuration"
You'll see the list of modules is better organized and has a filtering option.
I install this on all my Drupal sites. And you should too.
Find and enable the options element module.
Click on "Structure", then "Content Types". Then "Manage Fields" next to "Task".
Then click on "Edit" next to the "Status" field.
Now you can add new options, drag them around, set the default value, all in one simple interface.
While you're here, add a status state called "In Progress"
(set the key to "inprogress")
Go back to manage fields for your Task node type.
Look for a Date field type.
Is there one? If not, what do we do?
Just kidding
Some modules come with "sub modules" which break up functionality into parts. That way you can turn on only what you need.
In our case, we just want the "Date" module itself.
Yeah that one.
Certain modules require other modules to work. Most of the time modules take care of turning on the ones they need.
Click "Continue"
Lastly, sometimes when you enable modules, they give you hints on how to set them up or use them.
Watch for messages at the top of the page after enabling modules.
Let's check the list of field types again.
You should see the "Date" option now.
Ignore the other date options. You'll likely never use them.
Let's set the date granularity and some global settings.
Use the site's timezone.
Turn on cache dates, leave the default settings for that.
Here we setup how users can enter dates.
Choose your date format, starting year, ending year, default date, etc...
Set these settings to whatever you think is right.
Save when you're done
Use the Pantheon Dashboard to save your work
A view mode is a way to render a single piece of content.
For example, the Article content type has two view modes; default and teaser.
Teaser is the shorter view you see on the homepage.
Default is the full page view with the comment form and all that when you view the article itself.
We can create / use view modes with our Task content as well.
On your content type page, click on the "Manage Display" link.
This will let you control how your fields show up based on the View Mode.
The list of enabled view modes for your content type are listed in the tabs at the top right.
Let's create a Task and adjust the View modes until we get it displaying the way we want.
Go to "Content" then "Add Content". Click on "Add Task".
Create a task called "Put task information side-by-side"
Fill in a description.
Set a due date.
In the publishing options, Promote to Front Page.
The simplest thing you can do is change the order of your fields.
Drag them around, click save and check out the change on your task.
Try putting date above description.
Try hiding the description in the Teaser view mode
Change the date format to be different in Teaser vs Default (hint: use the gear next to the date field)
This module adds more controls and options to your "Manage Display" page.
Most importantly, it lets you select other layouts other than the standard single column we've been using.
That's right. You're on your own this time. Find the download link, add the module and enable "Display Suite UI" on your site.
I'll wait...
I'm just teasing. Take your time and do it right.
Go back to Manage Display.
Go to the Teaser view mode.
Select the Fluid Two Column stacked layout.
You'll notice you have a lot more options now. Display Suite also let's you control non-field items like the content post date, the author, and other stuff.
Place your items in the left or right column as you like.
Display Suite also lets you move the Title around. It also however defaults the title to not be a link.
Let's set the title to link to the content again.
http://drupal.org/project/boostrap
You install themes the same way as modules, but you enable them on a different page.
Click on "Appearance" and you'll see Bootstrap listed.
Click on "Enable and set default"
Disable using the admin theme for content editing. Let people use the Bootstrap theme instead.
Bootstrap needs a newer version of jQuery to run than what Drupal comes with.
Thankfully, there's a module for that.
http://drupal.org/project/jquery_update
Using the "Configuration" link, scroll down until you see "jQuery Update" in the "Development" settings section.
The configuration section in Drupal is where you go to change most of the global settings for your site.
Each configuration group contains the core settings as well as any module specific settings.
When you setup a Drupal site, odds are you'll visit this page a lot in the beginning.
But once everything is up and running in production, you probably won't (or shouldn't) change stuff here unless you have to.
Leave the "Default" jQuery version at the latest version.
Change the "alternate" version to be 1.5
This will let your administrative modules work properly.
Give a try at editing your task.
You should see the Bootstrap theme now instead of Bartik.
Add a task for "Create a task list"
Add a task for "Add a menu for creating tasks"
Add a task for "Link to my task list from the main menu"
Right now, the only way to get a list of our tasks is either by publishing them to the front page (which gets mixed in with other content) or using the admin/content page (which once again, has everything).
You should know what to ask yourself right now. And what the answer is...
We need a module.
Find the download link and add it to your Drupal site.
If you go to your Modules page, you'll see you can't turn Views one yet.
You have missing dependencies.
Google "drupal ctools" and find the module and add it.
Google "drupal ctools"
Now that you've added Ctools, try to enable "Views UI"
Views let's you do three very important things:
After installing the module, click the "Configure" link.
Add a new view
Let's create a list of tasks.
Set the name to "Tasks"
Add a description
Show "Content" of type "Task" sorted by "Newest first"
Create a page at "/tasks"
Create a menu link in "Main Navigation" and "Use a Pager"
And you have a view!
Open a new tab and go to "/tasks" on your site.
You should see a list of tasks.
Let's add some tasks to make our task list better!
On the left hand side, under "Navigation", use the contextual links gear and select "List links"
Change the order of the links. Put "Task" at the bottom.
Edit the "Task" link and rename it to "Add Task"
Go back to /tasks
You can now in one click add a task.
Let's get Views to output the count of the results above the list.
Click on "Header" in the "Page Settings" section.
The header settings allow you to add content above your Views.
Add a "Global: Result Summary" to the header.
You'll see some "tokens" in the text.
Tokens are special words which get replaced with information when the view is displayed.
Adjust the text as you like.
You now have the count at the top of the page.
Mark that task as "completed".
Things are starting to come together.
What's next?
Why shouldn't we be able to add images to tasks?
Let's go back to Manage Fields
Have a look at the existing image fields (i.e. field_image)
Does it meet our needs? (add the existing field and have a look at the settings)
Now that we have a new field, let's setup how we show it.
Go to Manage Display. Choose Teaser view.
Change the layout to "Three Column Fluid"
Now that we have an image, let's make sure it gets sized right.
Put the image in the left hand column.
Edit the image field display settings (look for the gear)
Drupal can resize images automatically for you when they get displayed.
Settings for displaying images are called "Image Styles"
You can add or edit the existing image styles in the Configuration section.
Look for "Image Styles"
We'll create a new image style later. For now, use Thumbnail.
All said and done, your task display should look like this.
Use the gear to edit the Task List view.
Click "Add" under sort criteria.
Look for "Due Date"
Check the box, click Add.
Sort criteria in Views can be exposed to the user. That let's the user choose how to sort things.
Check off "Expose this sort..."
Set the default sort to "Ascending"
Save your View and voilà
In the "Filters" section, Add the "Status" field.
Filters can be exposed just like sorts.
Expose this filter, let people choose their status options.
Save your view and BAM! Filter by status. Getting the hang of things?
You can reuse a configured View to show the same (or very similar) list of content in different ways.
We'll add a display specifically for Completed tasks.
Lots of stuff to setup...
Views displays by inherit settings from the default display.
If we want to make changes that only affect this display, we need to make sure we always set...
The Admin Title is already set for this display, so no button required.
Look for the "Display Name" section.
The Display Name is only used by administrators. Users won't see this.
Now we're getting into overriding settings. Click on the "Title".
Select "This display (override)" in the select box.
Change the title to "Completed Tasks"
Overridden settings appear italicized
Instead of exposing the "status" filter, we'll fix it to "completed"
Set to "This page (override)"
Edit the "Status" filter, uncheck "Expose".
Set to "Complete" and "Is one of".
This setting doesn't need to be overridden.
Change the path to "tasks/completed"
Check the Preview at the Bottom. Save if it looks good.
Go to "tasks/completed".
Almost there, but we're missing the tab.
Select "Menu Tab"
Set the title to "Completed"
Choose "Main Menu" under "Menu"
(This image shows "Navigation", don't do that...)
We've setup the "Completed" page to show up as a tab.
Now we need to change the main "Task" list display as well.
The main task display is our "Default menu tab"
Drupal's menus are kind of weird. Follow along and don't be afraid to ask questions.
Edit Path settings
Change to "tasks/list"
Edit the Menu settings
Change it to "Default Menu Tab"
Set the title to "Tasks"
Set Menu to "Main Menu"
Save and you should have tabs
(It's ok if you don't, menus are weird)
Added a Views Display
Added menu items
Added filters
Added sorts
Let's go over the Drupal configuration pages
Instead of having to update your tasks one at a time, why not update a bunch at once?
Add two new modules
Views Bulk Operations
Entity API
Enable Views Bulk Operations
Change the "Format" from "Content" to "Fields"
Gives us more granular control over the displayed content in Views.
We'll add the "Bulk Operations" checkbox for each task.
Click "Add Field" and choose "Bulk Operations: Content"
Choose "Modify Entity Values" in the list of options.
Select the "Fields" you want to be able to update (ex: Status, Due Date)
Choose your modifiable values
We'll get views to also display our task in "Teaser" mode.
Click "Add Field"
Choose "Rendered Content"
Set Display to "Show complete entity"
Set View Mode to "Teaser"
Change your HTML format to "Table" from "HTML list"
Reorder the fields to the right order.
(Use the arrow dropdown next to "Add" and choose "Rearrange")
Put the Bulk Operations first, rendered node second.
Feel free to tinker with some settings.
Try out some options, see what you like.
Checkboxes and Updates
Entities are a higher level type of content.
Nodes are entities
Users are entities
Comments are entities
etc....
We can reference any entity from another.
That means we can "Assign" a "User" to a "Task".
Or we can "reference" a "user" from a "node".
Add a new field called "Assignee"
Select "Entity Reference" and set the widget to "Autocomplete"
Choose the "User" entity type.
Save settings
Configure the field like any other.
New field means new display options.
Configure the reference to link to the user.
Drag it to a column you'd like.
Edit a task and assign it to your user.
You can create more user accounts.
Better yet, share a link to your site with a course mate. Have them create an account.
If you don't have anyone to sign up or share you site with, we can generate some users.
If you don't want to have to continue to create new tasks, we can have Drupal generate some dummy content.
This module is strictly a development tool.
But it's super handy.
Configuration then Generate Users
Pretty simple list of options.
Create 10 users.
Similarly, you can generate content under the Configuration page.
Typically, you always want to generate users first since content needs a user, but a user doesn't need content.
If we've reached this point, I'm sure there has to be some questions.