Drupal development

From Things and Stuff Wiki
Jump to navigation Jump to search


needs refactoring to work with theming

See Building Distros Theming / Aegir

General

  • Drupal dev docs - "Newcomers to Drupal development should read the conceptual information provided in the 'Components of Drupal' section, and then proceed to examine one of the heavily-documented example modules below. The examples are fully-functioning Drupal modules, so you can download them from the contributions repository and alter them as you experiment."

Multisite

Drupal.org

see project page right sidebar links for git, patches pending, etc.


CLI

Composer

composer update 'drupal/*' --with-dependencies
php -d memory_limit=-1 composer require zaporylie/composer-drupal-optimizations

Drush

  • Drush - a command line shell and Unix scripting interface for Drupal. Drush core ships with lots of useful commands for interacting with code like modules/themes/profiles. Similarly, it runs update.php, executes sql queries and DB migrations, and misc utilities like run cron or clear cache. Drush can be extended by 3rd party commandfiles.
composer require drush/drush



Commands

I have dr as an alias for drush.


drush updatedb --no-interaction --yes

drush watchdog:show


drush help
  alll the commands!
drush help --filter
  choose which help category to echo
drush cc all
  clear cache
drush pml
  list installed and enabled modules

drush dl [project]
  download project
drush dl sasson-7.x-3.x-dev
  download sasson dev release
drush updb
  run upgrade.php
drush en [project] -y
  enable project without confirmation
drush dis [project] -y
  disable project

drush pm-uninstall [project]
  remove project from db
drush sql-cli < example.sql
drush php-eval 'echo drush_get_context("DRUSH_DRUPAL_ROOT");'
drush php-eval 'echo drush_locate_root() . "/" . drupal_get_path('theme', 'sasson');'

drush eval 'echo theme_get_setting('sasson_compiler') . "\n" ;'
  otherwise gives trailing issue?
drush vset --yes site_offline_message "This site is being maintained";

drush vset --yes site_offline 1;

In Drupal 7 to simply put the site into maintenance mode:

drush vset --yes maintenance_mode 1;
drush user-login ryan
  displays a one-time login link for the user ryan. 
open `drush user-login ryan`
  open said link in browser
dr uli

Site aliases

Drush uses site alias files to store context data. (Aegir still uses Drush 4)

drush help site-alias

Copy to ~/.drush, rename aliases.drushrc.php or further.

drush ev 'print_r(array_keys(drush_sitealias_get_record("@server_master")))'
drush ev '$a = drush_sitealias_get_record("@gk.dev"); print_r($a["path-aliases"]);'
Deployment

To sort with Aegir#Remote

drush help rsync
drush help sql-sync

Drupal Console

Site build

See Profiles

Two make files; mysite.build and mysite.make.

mysite.build is brief:

core = 7.x
api = 2
projects[drupal][type] = "core"
; Our distribution
projects[mysite][type] = "profile"
projects[mysite][download][type] = "git"
projects[mysite][download][url] = "git@gitserver.com:mysite.git"
projects[mysite][download][branch] = "develop"

mysite.make contains the list of modules, themes, and libraries to download and add to the site.


Debugging

Troubleshooting

$config['system.logging']['error_level'] = 'verbose';
  # in sites/default/settings/php


Modules

dpm()


Admin

https://www.drupal.org/project/admin_toolbar - better menu system all-round




Content




Module Admin



  • https://github.com/makinacorpus/drupal_audit - This shell script allows a quick "audit" of a website, giving some details about the configuration: drush status, hacked status (using Hacked module), modules & themes status, cache status (using Cacheaudit module), database volumetry indications, phpinfo() ...

Coding

Basics

$variable_name

Modules

Patches

patch -p1 < path/file.patch

or

git apply path/file.patch

Hooks

"Drupal's module system is based on the concept of "hooks". A hook is a PHP function that is named foo_bar(), where "foo" is the name of the module (whose filename is thus foo.module) and "bar" is the name of the hook. Each hook has a defined set of parameters and a specified result type.

"To extend Drupal, a module need simply implement a hook. When Drupal wishes to allow intervention from modules, it determines which modules implement a hook and calls that hook in all enabled modules that implement it."

Menu system (path)

Content

Entities

An entity can be a kind of content stack. An entity base table is tied to fields using bundles. Entity types include node, comment, taxonomy term, user profile, organic group, etc. Entity types can allow bundling or not (creating types of node vs. users, though see the Profile 2 module). Fields are used to store and display various data types, and can be reused across bundles and entities.

(that was about right the last time I dived in)

hook_entity_info - "Inform the base system and the Field API about one or more entity types."

Ctools

Chaos tool suite (ctools) suite is primarily a set of APIs and tools to improve the developer experience. It also contains a module called the Page Manager whose job is to manage pages. In particular it manages panel pages, but as it grows it will be able to manage far more than just Panels.

For the moment, it includes the following tools:

  • Plugins -- tools to make it easy for modules to let other modules implement plugins from .inc files.
  • Exportables -- tools to make it easier for modules to have objects that live in database or live in code, such as 'default views'.
  • AJAX responder -- tools to make it easier for the server to handle AJAX requests and tell the client what to do with them.
  • Form tools -- tools to make it easier for forms to deal with AJAX.
  • Object caching -- tool to make it easier to edit an object across multiple page requests and cache the editing work.
  • Contexts -- the notion of wrapping objects in a unified wrapper and providing an API to create and accept these contexts as input.
  • Modal dialog -- tool to make it simple to put a form in a modal dialog.
  • Dependent -- a simple form widget to make form items appear and disappear based upon the selections in another item.
  • Content -- pluggable content types used as panes in Panels and other modules like Dashboard.
  • Form wizard -- an API to make multi-step forms much easier.
  • CSS tools -- tools to cache and sanitize CSS easily to make user-input CSS safe.
  • Ctools Plugin Stub is a Drush plugin that can help you generate code stub files for ctools plugins. I wrote this plugin after having consistently messed up names of hook implementations in plugins over a long period. Plugin Stub does not write actual code that *does* stuff for you, but it sets you up so that all you have to do to get started is to fill in the capitalized parts of the generated file and start writing code that *does* stuff.

Menus

JavaScript

Video

Adding a JS file

In theme .info;

scripts[] = scriptfile.js

In template.php;

drupal_add_js()
  first paramater path
  second paramater (goes through as 'type: ' array item, defaults to file)
    file, setting, inline, external
    default: preprocess: true, everypage: true, 
    weight:
$element['#attached']['js']

Drupal JS API and Behaviours

Drupal has an API for passing information between PHP and JS. Drupal.js sets up Drupal namespace.

Render Array

PHP sent by JSON to change content.

jQuery

The .ready() function also has the ability to alias the jQuery object:

jQuery(document).ready(function($) {
  // Code that uses jQuery's $ can follow here.
});

AJAX

JSON


wip; still merging in from Modules and rearranging

General


  • https://www.drupal.org/project/libraries - The common denominator for all Drupal modules/profiles/themes that integrate with external libraries.This module introduces a common repository for libraries in sites/all/libraries resp. sites/<domain>/libraries for contributed modules.


  • http://drupal.org/project/features - The features module enables the capture and management of features in Drupal. A feature is a collection of Drupal entities which taken together satisfy a certain use-case. Features provides a UI and API for taking different site building components from modules with exportables and bundling them together in a single feature module. A feature module is like any other Drupal module except that it contains additional information in its info file so that configuration can be checked, updated, or reverted programmatically.


Admin

  • https://www.drupal.org/project/module_filter - quickly find the module you are looking for without having to rely on the browsers search feature which more times than not shows you the module name in the 'Required by' or 'Depends on' sections of the various modules or even some other location on the page like a menu item.
  • https://www.drupal.org/project/masquerade - allows site administrators (or anyone with enough permissions) to switch users and surf the site as that user (no password required). That person can switch back to their own user account at any time.


  • https://www.drupal.org/project/total_control - Several overview panes are included for site stats and quick reference. Several administration panes are provided with quick links to content types, menus, taxonomy, and other scattered locations of important Drupal site administration. Several views panes are also provided as well as full-page comprehensive versions of the views with bulk operations. Each views panel pane is customizable via it's pane settings, or override the default views provided to suit your own needs.



Workflow

Editing of submitted unpublished nodes, updating coordinator contact info, etc.


  • https://www.drupal.org/project/maestro - This is not a just a clever saying. It's true. With Maestro, the method to automate your process starts with our visual workflow editor with which you drag, drop and connect your workflow steps together. The maestro workflow editor can be used by business users to map out their business process.


  • https://www.drupal.org/project/override_node_options - The Override Node Options module allows permissions to be set to each field within the Authoring information and Publishing options field sets on the node form. It also allows selected field sets to be set as collapsed and / or collapsible.


  • http://drupal.org/project/rules - The Rules module allows site administrators to define conditionally executed actions based on occurring events (known as reactive or ECA rules).



Antispam

E-mail

Layout

Spaces

Blocks

Views

Views is used to display bits of content in various fashions.

  • How to display content nodes using Views 3: *to source again*

API

Modules


Menus

Aggregation

Context

Display Suite

  • Display Suite allows you to take full control over how your content is displayed using a drag and drop interface. Arrange your nodes, views, comments, user data etc. the way you want without having to work your way through dozens of template files. A predefined list of layouts (D7 only) is available for even more drag and drop fun! By defining custom view modes (build modes in D6), you can define how one piece of content should be displayed in different places such as teaser lists, search results, the full node, views etc.

Docs

Articles

Videos

Panels

Nodequeue

Manual list of content items, can be used in Views.

Path

Title

Menus

  • https://drupal.org/project/floating_block - keep html blocks, selected using jquery selectors in a fixed position on the page as you scroll. It works in a similar way the table header fixer in Drupal Core.
  • Custom Active Menu Item - provides an easy way to indicate which menu item is active adding the active CSS class depending the path that the users are seeing.

Breadcrumbs

or check your theme page.tpl.php

Links

Content

to sort;

Entities


Fields

Bundles

Nodes


all needs moving to contrib and more.

Forms

Aggregation

GUI

Typography


Comments

Javascript

Adverts

  • http://drupal.org/project/openx - Show ads from a OpenX (formerly OpenAds) server. OpenX is a open source online program that will allow you to catalog and display advertisers, just like Google, Yahoo or Microsoft.

Internationalisation


Media

  • http://drupal.org/project/media - provides an extensible framework for managing files and multimedia assets, regardless of whether they are hosted on your own site or a 3rd party site - it is commonly referred to as a 'file browser to the internet'. Media is a drop-in replacement for the Drupal core upload field with a unified User Interface where editors and administrators can upload, manage, and reuse files and multimedia assets. Any files uploaded before Media was enabled will automatically take advantage of for many of the features it comes with.
  • Displaying Media - The File Entity and Media modules work together to provide a unified method for storing, managing, and displaying Media in Drupal. They allow a user to create file fields that can be configured to store and display many different types of media, including images, video, and audio, sometimes created by Media provider modules (e.g., Media: YouTube, Media: Soundcloud, or OEmbed). In order to display these different types of media, file fields use formatters, often added by the provider module, that need to be configured when setting up your site.

Embedded Media Field

  • http://drupal.org/project/emfield - create fields for content types that can be used to display video, image, and audio files from various third party providers. When entering the content, the user will simply paste the URL or embed code from the third party, and the module will automatically determine which content provider is being used. When displaying the content, the proper embedding format will be used.

Imagecache / filters

Lightbox

Gallery

  • http://drupal.org/project/node_gallery - create multimedia galleries where both the galleries and the gallery items are nodes. (as opposed to gallery items being file fields, like Media Gallery)
  • Galerie provides (hopefuly) easy to use and clean galleries based on an API/submodules model. galerie itself provides a "galerie" node type and manages the display of galleries (classic thumbnails and large images view, and slideshow mode) while submodules retrieve content from different sources: local files, Flickr or Tumblr for now.

other

  • File Lock - gives the possibility to "lock" files. Locking files means adding an extra file_usage entry, because Drupal will delete files which aren't used anymore. But by now there is no possibility to keep "unused" files.
  • http://drupal.org/project/plup - doesn't use plupload module. straight attaches image to end of node, no display config other than image field manage display settings. very basic media integration - broken preview and no way to hide otherwise attached images on per node basis.

untested;

Adaptive/responsive

Retina

Flickr

  • http://drupal.org/project/flickr - Access photos on Flickr's site via their API. The module provides a filter for inserting photos and photosets and allows the creation of blocks for rendering a user's recent photos and photosets. The filter format is: [flickr-photo:id=230452326,size=s] and [flickr-photoset:id=72157594262419167,size=m]
    • doesn't use image styles
  • http://drupal.org/project/media_flickr - The Media: Flickr project currently offers Flickr Photoset capabilities to the Embedded Media Field module, upon which this module is dependent. To use it, enable the Embedded Video Field module, and add a Third Party Video field to a content type.

Scald

Audio

  • http://drupal.org/project/audio - allows users with proper permissions to upload audio files into drupal. Each audio item is created as its own individual audio node. The audio module uses the getID3 library to read and write ID3 meta-tag information to and from the audio file. Pages that display the most recent audio files submitted to the site, as well as the most recent audio files uploaded by individual users are also generated. Feeds from these pages are 'podcast friendly'. The module also comes with the handy XSPF Flash player that is (by default) embedded in your site.
  • http://drupal.org/project/filefield_audio_insert - extends the functionality of the cck filefield module. It allows you to insert flash playable audio into textareas/body's of nodes. It works in conjunction with the mp3player module for audio playback.
  • http://drupal.org/project/debut_audio - A baseline embedded audio feature.Audio content type with embedded audio field supporting multiple external providers. Audio view with page listing, recent audio files block, and RSS feed. etc.
  • http://drupal.org/project/audiofield - allows you to upload audio files and automatically displays them in a selected audio player. Currently it supports 6 players and it provides API for easy addition of new players.
  • http://drupal.org/project/audioconverter - converts audio files from supported CCK fields (AudioField, AudioRecorderField) to the mp3 format using FFMPEG. Depending on the need, files can be converted on cron or whenever new audio content is submitted.
  • http://drupal.org/project/jplayer - provides a wrapper around the jPlayer JavaScript library. This library provides an HTML5-based player, that uses a Flash fallback for browsers that do not yet support it. This module provides a default presentation for the player, as well as integration with CCK file fields and a display style for Views.
  • http://drupal.org/project/mp3player - WordPress Audio Player to Drupal. Easily enable the MP3 Player on a CCK FileField. Setup multiple players each with their own settings and appearance. FileField and Views support.

Forms

Webform

Events

  • Date contains both a flexible date/time field type Date field and a Date API that other modules can use.
  • Calendar will display any Views date field in calendar formats, including CCK date fields, node created or updated dates, etc. Switch between year, month, and day views. Back and next navigation is provided for all views. Lots of the Calendar functionality comes from the Date module, so any time you update the Calendar module you should be sure you also update to the latest version of the Date module at the same time.
  • partial_date provides date and time fields that allows any individual component to be left blank, while still providing a sortable listing of the fields. Useful if you need to handle dates like "8:46 a.m Sep 11, 2001 EST", "12 noon 25 May, Early 16th Century" or "May 20000 BC" in the one field.
  • Scheduler allows nodes to be published and unpublished on specified dates.
  • Signup allows users to sign up (or register, as in register for a class) for nodes of any type. Includes options for sending a notification email to a selected email address upon a new user signup (good for notifying event coordinators, etc.) and a confirmation email to users who sign up.

Timeline

Tracker

Mapping

Spreadsheets

Books

Shortcodes

Files

Extras

Search

Notification

  • Messaging allows message sending in a channel independent way. It will provide a common API for message composition and sending while allowing plug-ins for multiple messaging methods.
  • Notifications is a complete Subscriptions/Notifications Framework aiming at extendability and scalability. It allows any number of plug-ins defining new event types or subscription types or a different user interface.
    • anon d6 only
  • Notify allows users to subscribe to periodic emails which include all new or revised content and/or comments much like the daily news letters sent by some websites. Even if this feature is not configured for normal site users, it can be a useful feature for an administrator of a site to receive notification of new content submissions and comment posts.
  • Subscriptions enables users to subscribe to be notified of changes to nodes or taxonomies, such as new comments in specific forums, or additions to some category of blog. Once enabled, all nodes will have an additional link that allows the user to change their subscriptions. Users have tab on their user screen to manage their own subscriptions. Users can also set an auto-subscribe function which notifies the user if anyone comments on posts they have made. Admins can turn this on by default.

Simplenews

Creating

WYSIWYG

See also WYSIWYG

Editing

Inplace / Inline

Embedding

External

Syndication

Semantic

External sources

Graphing

Attention

Interface

Booking

Taxonomy

  • http://drupal.org/project/content_taxonomy - D6, This module provides a CCK field type for referencing taxonomy terms. The fields are independent from vocabulary settings. For every field you can specify settings. D7,

to sort;

  • http://drupal.org/project/textmining_api - simple pluggable framework module that handle node/taxonomy terms/text fields association process for tagging/metadata services with submodules providing OpenCalais and Tagthe.net support

Token


  • Token Filter is a very simple module to make token values available as an input filter.

Users

Registration

Permissions

Spam and captchas

Login

Cookies

Passwords

Social

Profiles

use relationship in views to access fields [6]

Content: Author, (author) User: Profile

Groups

D6 OG

  • http://drupal.org/project/og_subgroups - enables a user with the proper permissions to build group hierarchies (or tree) by nesting groups under other groups. Simple or complex group hierarchies can be easily created.
  • http://drupal.org/project/og_features - allow group owners and site administrators to disable certain features/functionality within a given group (without the use of the Spaces module).
  • http://drupal.org/project/og_privacy - define the rules by which organic groups posts will be visible to non-group members. It is an API module which allows developers to create access policies which override the default behavior of OG Access and Spaces OG.
  • http://drupal.org/project/og_invite_link - OG Invite Link overrides the user invitation form that comes with OG - used to invite non-members to a given group. The key difference is that invitation emails contains a special tokenized invitation link, meant specifically for that user.
  • http://drupal.org/project/og_titles - extends group membership to include arbitrary titles with which you can add to Organic groups views. Titles are per member and arbitrary strings. Examples of titles are strings such as "Chairman", "Secretary", or "Really Cool Dude". These can be accessed via Views.
  • http://drupal.org/project/og_access_roles - extends the reach of Organic Groups' bundled Organic groups access control module by allowing node authors finer control over who can see their posts. Organic groups access control gives node authors the option of making their posts Public, meaning anyone can view the node, even anonymous users; or Private, meaning only group members can view the node. For Private posts, OG Access Roles gives node authors the ability to let users in selected roles view nodes even if those users are not in the group (or groups) where the node is posted.
  • http://drupal.org/project/og_perm - In the OG module all group admins currently have the same set of capabilities within their group. They can add/ remove members, broadcast messages, and create/remove group admins. This module requires that group admins also have a certain permission to get those capabilities.
  • http://drupal.org/project/og_massadd - Overrides the internal "add users" page of Organic Groups with a more powerful alternative. Takes a list where each row can be either: username - mail address - firstname, lastname, mail address - firstname, lastname, mail address, desired username.
    • In case 1 or if there is an mail address provided, the module first checks if it matches an existing user, and adds that user to the group.
    • In case 2-4, if there is no matching user, the user will be created (as long as the person submitting the form has permissions to do so). Newly created users will also have a content profile node created for them if enabled (has a settings page).
  • http://drupal.org/project/og_read_only - allow group administrators to set some content types as "read-only". Read only types can't be posted by simple group members, but still can be posted by group managers and users with "administer nodes" permission. Wiki group types can't be set to read only.
  • http://drupal.org/project/og_node_approval - offers content review between group members allowing them to approve or reject content. When creating or updating content simply choose the audience for the content (including multiple groups), save the node, and the module will insert group members from those respective audiences into the a node approval table.
  • http://drupal.org/project/og_audience - allows Organic Groups (OG) users to change a node's audience without having to edit the node. This module works by providing a new change audience permission, and an Audience tab and/or block on node pages that allows users to change the audience of existing content. A user can add any node to one or more of the groups he/she has subscribed to. A group manager can remove a node from his/her group(s). A node's author can remove the node from one or more of the groups he/she has subscribed to.
  • http://drupal.org/project/og_teams - create groups of users (teams) that can be subscribed to organic groups just like regular users. Teams are like user roles, you can create new teams and you can assign multiple users to any team.
  • http://drupal.org/project/og_mandatory_group - makes one group mandatory for all new users and/or requires new users to pick a group. Choose one group that all new users will be put into. You can chose either an open or a closed group. Any new user will be auto-approved as member of the group. The group manager(s) of groups that a new user joins will get an automatic e-mail notice.
  • http://drupal.org/project/og_manage - added tab to user account where administranor can select groups user belong to and make user of this groups or remove membership on one page.
  • http://drupal.org/project/ctog - Running Case Tracker and Organic Groups on the same site raises some questions - but CTOG helps solving them by utilizing some rules to tie them together in a way which makes them easier to use.
  • http://drupal.org/project/og_mailinglist - OG Mailinglist allows users to start new discussions by email and post comments on existing discussions by simply replying to emails. You get the best of both worlds: a browser-based discussion site and an email-based list.

Party

Internal network

Private messaging

Comments

Groups

Social and sharing

External integration

Facebook

Twitter

  • http://drupal.org/project/twitter_pull Twitter Pull is a small module, the only purpose of which is to allow super-easy embedding of public twitter data like: a user timeline or twitter search results by hashtag or a search term. The emphasis is on making these very specific tasks as easy and straightforward as possible. The purpose of the module is not to be an end-all solution for Twitter.

Google Plus

Sharing

External

Social service

Comms

to sort

Federation

DiSo, etc

Other

Eye candy

Countdown

External links

Aggregation

Feeds

Views owner node title - http://drupal.org/node/1257170

OpenCalais

E-commerce

See also Drupal Distros#E-commerce

Payment

  • Payment is a general payment platform which allows other modules to use any of the payment methods that plug into Payment. With Payment we only need one one Paypal, one credit card and one iDEAL module to use with every single webshop or payment form that you want (applies to any payment method that works with Payment). This shortens development time and improves support, because only one instead of three Paypal modules need to be maintained, and simplifies UX, because all payment (method) information is now located in one place.

Payment method controller modules;

Other

Performance

Boost

  • Boost provides static page caching for Drupal enabling a very significant performance and scalability boost for sites that receive mostly anonymous traffic. For shared hosting this is your best option in terms of improving performance. On dedicated servers, you may want to consider Varnish instead. Apache is fully supported, with Nginx, Lighttpd and IIS 7 semi-supported. Boost will cache & gzip compress html, xml, ajax, css, & javascript. Boosts cache expiration logic is very advanced; it's fairly simple to have different cache lifetimes for different parts of your site. The built in crawler makes sure expired content is quickly regenerated for fast page loading.

CloudFlair

Other


SEO

Analytics

Humour

Project

  • http://drupal.org/project/merci - can extend any content type into a list of unique reservable items (like studios) or buckets of interchangeable items (like DV cameras). We followed the approach used by Organic Groups, Feed API, and Scheduler and added MERCI's configuration to the Edit tab of those content types.