Starting Your Journey Using Drupal
Drupal is a popular CMS framework written in PHP and has a wealth of features and components to help build any sort of website you need — while it can be difficult to master the many aspects of Drupal there is a lot you can do with little or no coding. In this post we will cover some of the Administrative and basic building blocks of a Drupal website:
- Beyond these basic building blocks …
Creating Custom Content
Drupal allows you to define custom data types, and the fields that comprise your custom data into reusable definitions as you define this data Drupal creates Forms that allow site users to create pieces of this custom content.
You can add content to your site, once you’ve logged in, at the path: http://yoursite.com/node/add or if clean-urls are disabled http://yoursite.com/?q=node/add. You can then select the type of content to create such as a Page and fill out the form:
The options for a standard drupal Page content include:
A page title (required)
The body of the page in HTML, you may specify an Input Filter if given permission.
Menu Settings — where the page lives in your site structure
Revision Information — you may supply a brief log message of your most recent changes
Url Path Settings — You may denote an alias beyond the default system node path of node/NID
Comment Settings — are comments allowed on this content entry
Authoring Information — describes whom (you) created this page; on a multi-user Drupal website this is useful information
Publishing Options — Is this published (available to the Web), or promoted to your homepage or is this content stuck to tops of content listings?
An example completed page Published and promoted to frontpage looks like the following in its final Edit view and Published on the website:
The live page on the website (our homepage in this case):
Additional Resources on Content Creation
- Display Suite: easily change out pieces of content are shown.
- Panels: advanced module provide ways to manage content display and linking beyond just Nodes and Blocks.
- Entity Construction Kit (ECK): create custom entities with your own fields.
Aggregating Remote Content
In addition to defining your own custom data in Drupal — Drupal can ingest remote content you’ve already created remotely using 3rd party Feeds. With some work you could ingest your personal Facebook posts, or that of your business to show them as sidebar content on your company website. An example of a site that offers public data feeds is CNN.com.
By simply enabling the Aggregator module from /admin/modules:
You may then go to Configuration -> Web Services and supply feed urls to be processed for new Posts / Content on your site:
And then supplying the link of a content feed such as:
Upon creating the feed resource it will have 0 items digested. You simply press Update Items and the Feed will grab new items. Drupals default Cron job will successfully process new feed items without even needing to configure a server-side Cron entry.
Initial Feed Creation:
After Updating Items from CNN:
You can then show recent top news stories on your website. Drupal automatically creates a Block of recent feed items to place on your site (you must still place the block somewhere). Or, if you’re feeling adventurous you can install the Views module and really customize how these listings of items are presented on your site. You may see the feed content at the non-public url of http://yoursite.com/aggregator/sources/1 it looks like the following:
Administering Site Users
You may use Drupal as a single-user website for a personal blog or portfolio. But it may also be used as an intranet site for your own business staff, or a paid-for-service subscription based website. A central aspect of having users on your site is managing them. Users can have Profiles and be assigned Roles as needed; Roles may be given permissions to perform certain actions on your site. You Administer users, Roles and Permissions at Admin -> People which resolves to the url http://mysite.com/admin/people.
Creating a User
Simply press Add User on the People Dashboard and fill out the required fields. Most users have similar common fields such as username, email and some defined roles.
Creating and Assigning Roles
If Drupals 2 default roles don t meet your needs. You’re free to create your own Roles and assign a custom set of Permissions to that Role. To view/create Roles click on Permissions in the People Dashboard and you will see a new local task for Roles:
Assigning Permissions to Roles
Permissions are simply checkboxes of “who can do what” you check off what permissions a user is granted. You may have any mix and match of permitted actions — but be sure you don’t leave out a critical permission when developing a workflow for a certain type of user.
Additional Resources on Managing Users:
Using Drupal Blocks
I’ve mentioned many times already the concept of blocks. A block is a piece of content in Drupal that doesn’t resolve to a page url. If you create new Page in Drupal it may become the url /node/34. A block is not reachable via the url typically. Blocks can be placed anywhere on a page; the header, food, left sidebar, right sidebar etc. They enhance the content on your site. Typically we use blocks to hold banner ads, legalise, a listing of related items to content on the page or perhaps menu navigation controls.
You create block content using the Blocks UI. Its construction is similar to a simple page and permissions can be assign for who may view the block — or what page(s) or locations it shows up on the website.
Creating a Block
A block can be created on your site using the BlocksUI. You can find the Blocks administration page at Admin -> Structure -> Blocks (the url /admin/structure/block). Blocks are enabled and configured per Drupal Theme.
At this time you should be familiar with a few items of any content you create. Most content contains a Title and a Body. Block content is no different with this (titles may be optional).
A difference from a Page or Article content is that Blocks contain visibility settings:
The visibility settings allow you define conditions for when this block is visible to an end-user. You can mix and match any conditions. Blocks can have a Weight assigned to them and can be stacked per region and theme.
Additional Block Resources
There are many interesting ways to use blocks in Drupal and a lot of powerful contributed modules to enhance them:
- Context: easily define conditions for when a block should appear.
- Node_block: Treat page content as a block — to achieve a listing of highlighted site content for example.
- Beans: a popular alternative to Core blocks that allow a developer to programmatically create block content.
Managing Where Things Live — Drupal Menus
We’ve touched so far on Drupal content: Main Page content such as Pages (or Articles), and supporting content such as Blocks. When creating a page I mentioned it could have a menu destination, similarly 1 of a blocks visibility options is Pages. These refer to available paths within the Drupal system. All websites are created by URL paths. These url paths examined as a group of related links can make up as a sitemap or siteindex. Drupal provides default paths for all created content as node/NID or user/UID, where NID and UID are internal database key ids to the unique row of content in a server-side database.
Content links may be placed into Menus in drupal. Additional’y with the pathauto and by enabling the Clean Urls option of Drupal (clean urls require proper webserver configuration) module we can create custom aliases for content on our site and also by using Menus in drupal control our site hierarchy (the sitemap).
Menus in drupal can be administered at Admin -> Structure -> Menus. By default Drupal provides various default menus — any menu in the system is automatically made into an available Block for use on your website.
- The Main menu can be thought of as the top level, or root of your sitemap.
- The User Menu contains account specific links for logged in users, such as edit your profile or the ability to log out.
- The Navigation Menu in drupal typically holds links available to authenticated (logged in) Drupal users based upon their assigned permissions.
- The Management menu holds Drupal administrative links used typically by the site administrator.
You may edit any url or link on your website as you see fit. Or even hide links from public visitors. When you edit a menu link you will see a form similar to the following:
Of note in this form is the Enabled flag and also the Weight value. These 2 items control if the link is visible and also its order within the same level of your sitemap. The Parent link controls who the parent item in the site hierarchy the page is below — this lets you nest the content in your website.
By using the Menu Administration for and also the Content creation forms you have a very simple means of creating nested/related content for your site.
Additional Menu Resources
- MenuBlock: Creates a block, which you can assign a rather intelligent Menu into — as you navigate the menu up or down the menublock shows differing levels of the menu based on the settings you provide.
Beyond These Basic Building Blocks…
Drupal out of the box is a very flexible content management system. In various sections above I have outlined additional contributed community modules that you may find helpful in managing and interacting with your Drupal website. Drupal is capable of managing tremendous websites and various workflows and complexities; understanding how Drupal achieves its goals and inter-operates is the beginning steps towards mastering Drupal. The more modules you choose to use on your website, the more you’ll learn how Drupal is designed to be a flexible piece of software.