Git Product home page Git Product logo

drupal7-boilerplate's Introduction

Drupal 7 custom module boilerplate

Full featured custom module boilerplate with already setup structure and default functionality. The module and all example code is built completely using Drupal best practices and standards.

See the version for Drupal 8 here.

Includes

  • Custom forms, validation and submit handlers
  • Batch jobs
  • Cron integration
  • Token integration
  • Skinr integration
  • Rules integration
  • Drush integration
  • Node and user tabs integration
  • Webform field implementation
  • Theme/template implementation
  • Separation of module code in appropriate files (.pages, .tokens, .forms, .admin, .batch)
  • Email implementation, including both - text only (default) and rich (HTML) emails
  • Custom helper functions for:
    • Generating a random string of arbitrary length
    • Get the list of all image styles on the site *
    • Get the list of all nodes on the site *
    • Get the list of all node types on the site *
    • Get the list of all users on the site *
    • Get the list of all roles on the site *
    • Get the list of all vocabularies on the site *
    • Check if a user has a specific role
    • Check if a request is an AJAX request. Useful when overriding tricky form elements, e.g. setting a default value on Addressfield on checkout page with Commerce.
    • Secure string comparison from HTTP Auth library of Zend Framework

* Admin form friendly - means you can use this output directly in select boxes or radio fields in admin forms.

Why are all those implementations necessary?

Most bigger websites will have a main custom module, with general system modifications or general features and additional custom modules focused on a particular functionality. This boilerplate is suitable for creating that main module.

How to use

Few different ways:

  1. Copy/paste the parts you need in your custom module.
  2. Clone the whole repo and make the following replacements:
    • Rename all boilerplate. files to YOUR_MODULE..
    • Replace all boilerplate (lowercase) words with YOUR_MODULE (lowercase as well).
    • Replace all BOILERPLATE (uppercase) words with YOUR_MODULE (uppercase as well).
    • Replace all Boilerplate (capitalized) words with YOUR_MODULE (capitalized as well).
    • Customize the code to fit your project.

Removing components

Not all projects will need every component that is included in this module. Below are instructions on how to remove those parts. If you want to do this after you have installed the module, don't forget to clear all caches after removing the components.

Sample pages
  • open boilerplate.module file and remove the boilerplate_menu() function
  • open boilerplate.info file and remove the following line: configure = admin/config/boilerplate/settings
  • remove or empty the boilerplate.forms.inc file
  • remove or empty the boilerplate.pages.inc file
  • remove or empty the boilerplate.admin.inc file
  • remove or empty the boilerplate.batch.inc file
Themable elements
  • open boilerplate.module and remove the boilerplate_theme() function
  • remove the /theme directory
Custom mailsystem
  • open boilerplate.module file and remove the following line: require_once dirname(__FILE__) . '/boilerplate.mailsystem.inc';
  • remove the boilerplate.mailsystem.inc file
Helper functions
  • open boilerplate.module file and remove the following line: require_once dirname(__FILE__) . '/boilerplate.helpers.inc';
  • remove the boilerplate.helpers.inc file
Tests
  • open boilerplate.info file and remove the following line: files[] = boilerplate.test
  • remove the boilerplate.test file
Views integration
  • open boilerplate.module file and remove the boilerplate_views_api() function
  • remove the /views directory
Token integration
  • remove the boilerplate.tokens.inc file
Rules integration
  • remove the boilerplate.rules.inc file
Drush integration
  • remove the boilerplate.drush.inc file
Skinr integration
  • open boilerplate.module and remove the boilerplate_skinr_api_2() function
  • remove the /skins directory

By: topsitemakers.com.

drupal7-boilerplate's People

Contributors

adrian-cid avatar aramboyajyan avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.