Skip to main content

Drupal 7 install profile stuff that everyone else magically knows

Posted on: Wednesday, 9 October 2013 @ 11:38pm
Blatting about

Seeing as I found little to nothing when searching for how to configure individual role permissions, editor settings and enabling contrib filters with an install profile, I made something on the off-chance it helps some other poor sap like me who doesn't automagically know where to look for these things.

Enabling filters provided by contrib modules

Search in the .module files for _filter_info. Some modules use the same format as Drupal filters of $filters['modulename_filter'], others don't. Typogrify doesn't:

  function typogrify_filter_info() {
  return array(
    'typogrify' => array(


so in the install profile it would look like:

  // typogrify
  'typogrify' => array(
    'weight' => 0,
    'status' => 1,


whereas Media does:

  function media_filter_info() {
    $filters['media_filter'] = array(

so it would go in the install profile like:

  // convert media tags
  'media_filter' => array(
    'weight' => 0,
    'status' => 1


Configuring Wysiwyg and [editor of choice]

I got a little help from a blog post by deimos on InternetDevels that was a lot more useful than the myraid of blog posts littering teh interwebz that were basically copy/paste of "How to Write a Drupal 7 Install Profile".

The bit we want is $profile['settings'] += array() from, or more specifically everything inside the array() and modify the bits you want:

  $settings = array(
    'default' => TRUE,
    'user_choose' => FALSE,
    'show_toggle' => FALSE,
    'theme' => 'advanced',
    'language' => 'en',
    'access' => 1,
    'access_pages' => "node/*\nuser/*\ncomment/*",
    'buttons' => array(
      'default' => array(
        'Bold' => 1,
        'Italic' => 1,
        'Underline' => 1,
        'Strike' => 1,
        'JustifyLeft' => 1,
        'JustifyCenter' => 1,
        'JustifyRight' => 1,
        'BulletedList' => 1,
        'NumberedList' => 1,
        'Outdent' => 1,
        'Indent' => 1,
        'Link' => 1,
        'Unlink' => 1,
        'Anchor' => 1,
        'Blockquote' => 1,
        'Source' => 1,
        'Styles' => 1,
        'Table' => 1,
        'Flash' => 1,
        'iFrame' => 1,
      'drupal' => array(
        'media' => 1,
        'teaser' => 1
  'toolbar_loc' => 'top',
  'toolbar_align' => 'left',
  'path_loc' => 'bottom',
  'resizing' => TRUE,

  // Also available, but buggy in TinyMCE 2.x: blockquote,code,dt,dd,samp.
  'block_formats' => 'p,address,pre,h2,h3,h4,h5,h6,div,blockquote',
  'verify_html' => TRUE,
  'preformatted' => FALSE,
  'convert_fonts_to_spans' => TRUE,
  'remove_linebreaks' => FALSE,
  'apply_source_formatting' => TRUE,
  'paste_auto_cleanup_on_paste' => TRUE,
  'css_setting' => 'theme',
  'css_path' => '',
  'css_classes' => ''


Pay particular attention to the buttons array, it has "default" (stuff the editor ships with) and "drupal" (provided by Drupal modules) arrays which are what the buttons need to be listed under. The array for the default buttons (to get the names) are in /sites/all/modules/wysiwyg/editors in the .inc file for whatever editor you're using (mine was, then just search for buttons.

Granting permissions to roles

The function is user_role_grant_permissions($rid, $permissions = array())

I coped the admin role from standard.install so the rid (role ID) was a matter of $admin_role->rid. The permissions need to come in an array of keys.

The section heading will tell you what module you need to look in. Then look in the .module file for hook_permission. To grant permissions for Media for example, in media.module there is:

  function media_permission() {
    return array(
      'administer media' => array(
        'title' =&gt; t('Administer media'),
        'description' =&gt; t('Add, edit or delete media files and administer settings.'),
      'import media' => array(
        'title' => t('Import media files from the local filesystem'),
        'description' => t('Simple file importer'),
      'view media' => array(
        'title' => t('View media'),
        'description' => t('View all media files.'), // @TODO better description
      'edit media' => array(
        'title' => t('Edit media'),
        'description' => t('Edit all media files.'), // @TODO better description


so if you want your user to be able to administer the media, the key to use would be 'administer media'.

For the node create/edit/delete, dive into the database and find the node_type table. Then what you need is the "type":

and it ends up looking like: create gallery_image content in my example there.

Giving permissions to use a text filter requires going through some other function so it's easier to make it a variable (and also in case someone decides to change the name of the filter on you):

You end up with something like:

  user_role_grant_permissions($admin_role->rid, array(
    'administer blocks',
    'access contextual links',
    'administer media',
    'import media',
    'edit media',
    'administer menu',
    'create gallery_image content',
    'edit any gallery_image content',
    'delete any gallery_image content',
    'create page content',
    'edit any page content',
    'delete any page content',
    'access site in maintenance mode',
    'administer taxonomy',
    'administer users',


This LinuxJournal article would have been INCREDIBLY helpful if I had found it while trying to do the above, however I fell over it while looking for information on how to get views into the install profile. It took a vaguely related Stack Exchange Drupal Answers question to get me onto probably to put the view into the .profile file. After failing I figured maybe it doesn't exist for a reason and just dumped it in a .module.


Just because it's not super clear in the api if you're like me and reading it at midnight:

First, build the actual view with the gui (unless you're some Views pro that can just bang them out in code), then export it and paste it into a text file (just in case).

name = modulename
description = write something useful and descriptive
core = 7.x



  function modulename_views_api() {
    return array(
      'api' => 3,

  function modulename_views_default_views() {
    // paste your exported view code here

    // Add view to list of views to provide.
    $views[$view->name] = $view;

    // if you have any more views repeat the above

    // At the end, return array of default views.
    return $views;


No comments yet

madamep Thursday, 10 October 2013 @ 12:56am [Permalink]
Hey you found it! Congrats.
bek Thursday, 10 October 2013 @ 8:54am [Permalink]

Eventually yes XD Think the variables I was originally looking for were red herrings ;)

Add new comment

The content of this field is kept private and will not be shown publicly.