In some cases customers ask for a long site slogan. On the Site Information page (admin/settings/site-information) you'll notice that the slogan field is limited to a maxlength of 128 characters.

Please refer to the comments of Gekiboy (D6) or Harmj (D7) to achieve this. The method in this post is not recommended:

In order to bypass this, find the following file: root/modules/system/system.module.

On line 173 (or nearby) you'll find the following line:

$type['textfield'] = array('#input' => TRUE, '#size' => 60, '#maxlength' => 128, '#autocomplete_path' => FALSE, '#process' => array('form_expand_ahah'));

Replace the number 128 (which indicates the maximum length) with the desired amount of characters, and save it. Now go back to admin/settings/site-information or refresh the page if you're already on it.

Comments

Gekiboy’s picture

This is not a good idea as it affects the default text field size for all text fields and makes a change to your Drupal core which would be overwritten if ever you update to a newer version. Instead it's better to use a hook_form_FORM_ID_alter() in a custom module to make this change. For example, if your module was called site_base, the function would look like this:

/**
 * Implementation of hook_form_FORM_ID_alter().
 */
function site_base_form_system_site_information_settings_alter(&$form, $form_state) {
  $form['site_slogan']['#maxlength'] = 256; // Or whatever number you would like to set it to.
}
cpelham’s picture

I created and installed a module containing the function above, careful to change the function name. I changed the maxlength to 1024 and then cleared cache. but the form still only allows 128 characters. my site is a Drupal7 site. Does that make any difference?

—————————

Christopher Pelham
Director
CRS (Center for Remembering & Sharing)
123 4th Ave, 2nd FL
New York, NY 10003
212-677-8621
www.crsny.org

HarmJ’s picture

The Drupal 7 form array is slightly different..

I used:

$form['site_information']['site_slogan']['#maxlength'] = 256;

if ($form_id == 'system_site_information_settings') {
		$form['site_information']['site_slogan']['#maxlength'] = 256;
  } 

And that worked for me.

liz.oh’s picture

New themer here. Where am I supposed to put this code? (At least the OP's suggestion was easy...)

HarmJ’s picture

Create a custom module (http://www.slideshare.net/tanoshimi/creating-custom-drupal-modules)
and use it in the hook_form_alter function, like this:

function YOURTHEMENAME_form_alter(&$form, &$form_state, $form_id)
  {

    switch ( $form_id )
    {
         if ($form_id == 'system_site_information_settings') {
		$form['site_information']['site_slogan']['#maxlength'] = 256;
        }
.....  
olak’s picture

for me (in a drupal 7 site) it worked like this:

<?php

/**
* Increase the length of the slogan.
* Implements hook_form_FORM_ID_alter.
*/
function MODULENAME_form_system_site_information_settings_alter(&$form, &$form_state, $form_id) {
  $form['site_information']['site_slogan']['#maxlength'] = 255;
}
?>

using modulename instead of themename.
found here: http://scito.ch/content/longer-slogan-text-drupal-7

esteinborn’s picture

In Drupal 8 you need to modify it to the following:

MODULENAME.info.yml:

name: Site Slogan Maxlength Modifier
type: module
description: 'Increase the max length for the site slogan field'
package: System Modification
core: 8.x

MODULENAME.module:

<?php

use Drupal\Core\Form\FormStateInterface;

function MODULENAME_form_system_site_information_settings_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
  $form['site_information']['site_slogan']['#maxlength'] = 500;
}
erjuni’s picture

This looks very straightforward. I created the module with the two files above, installed it, enabled it. But the slogan field is still limited the same as before. I did flush all cache just in case.

Any suggestion on where to look?

Sergio Arbarviro’s picture

I scrupulously followed your instructions. When using the compressed .tar.gz file to install the new module, I get the error message:
"Unable to create directory 'temporary://update-extraction-7a97f8d7/.' "
I thus can't even install the custom module - and have not been able to check its effectiveness.

Does anyone have a clue on how to solve this?
Kind regards.

hawkeye.twolf’s picture

It sounds like your web server does not support uploading modules that way. Try uploading the folder to the correct directory (sites/all/modules) via FTP or some other mechanism, then visiting the Modules page again to turn it on. See documentation on installing modules for Drupal 7 or Drupal 8.

Hawkeye Tenderwolf
a Senior Developer
at Lullabot

andypost’s picture