Hi Today I found this module. and tried to work with it but I am getting error while going to add new subsites. Please check the attached image.

I don't know am I missing any configuration or not. but it seems "menu_name" in "subsites" table does not allows null values. Also "menu_name" in "menu_custom" table in "Varchar(32)"

CommentFileSizeAuthor
subsite-menu-creation error.jpg71.97 KBjonline
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

davyvdb’s picture

Is the menu module enabled?

Can you give the full error message?

Does the menu_custom table exist?

jonline’s picture

Hi Davy

Thanks for your reply.

- Yes Menu module is enabled
- menu_custom table is exist
- I have already attached the full error message

I partially solve that issue. What I did

I have change "menu_name" field to allow "NULL" into "subsites" table.

Please check "subsites_add" method into "subsites.helpers.inc"

     // insert in db
  db_query("INSERT INTO {subsites} (name, pages, visibility, theme, weight, status) VALUES('%s', '%s', %d, '%s', %d, %d)", $name, $pages, $visibility, $theme, $weight, $status);

Here "menu_name" field is not present which is not allows "NULL" values, So its generate an users warning "Field 'menu_name' does not have a default value"

  // create menu
  $menu_name = _subsites_create_menu($sid, $name, $name);
  db_query("UPDATE {subsites} SET menu_name = '%s' WHERE sid = %d", $menu_name, $sid);

Another warning generates "Data too long for column 'menu_name' " here "menu_name" is VARCHAR(32). that means if user enter a title more than 32 character then it generate another warning.

hope this will help you.

Note: great module indeed :)

davyvdb’s picture

Thx!

Does replacing

$menu['menu_name'] = sprintf('subsite-%d-%s', $sid, _subsites_slug($title))

with

$menu['menu_name'] = sprintf('subsite-%d-%s', $sid, _subsites_slug($title, 32)); // maximum menu_name length is 32

fix the 2 issues?

jonline’s picture

Thanks for quick reply.

This will solve second issue. To solve the first issue need to change line 51 in "subsites.install"

      'menu_name'     => array('type' => 'varchar', 'length' => '32', 'not null' => TRUE),

with

      'menu_name'     => array('type' => 'varchar', 'length' => '32', 'not null' => FALSE),
davyvdb’s picture

But does the first issue need to be solved? There should always a menu be created. So I'd assume that if the second issue is fixed, the first one is fixed too. Could you verify this?

jonline’s picture

I think this is necessary because

function subsites_add($name, $pages, $visibility, $css, $theme, $weight, $status) {

subsites are created here and menu_name is not present here but menu_name does not have a default value, so this will propagate a warning

  // insert in db
  db_query("INSERT INTO {subsites} (name, pages, visibility, theme, weight, status) VALUES('%s', '%s', %d, '%s', %d, %d)", $name, $pages, $visibility, $theme, $weight, $status);

  // fetch sid
  $sid = db_last_insert_id('subsites', 'sid');

  // create menu
  $menu_name = _subsites_create_menu($sid, $name, $name);
  db_query("UPDATE {subsites} SET menu_name = '%s' WHERE sid = %d", $menu_name, $sid);

  // create subsite menu item
  $path = 'admin/build/subsites/';

  $menu['title'] = $name;
  $menu['description'] = '';

  $link['link_title'] = $menu['title'];
  $link['link_path'] = $path . $sid;
  $link['router_path'] = $path .'%';
  $link['module'] = 'subsites';
  $link['weight'] = $weight;
  $link['plid'] = db_result(db_query("SELECT mlid FROM {menu_links} WHERE link_path = '%s' AND module = '%s'", 'admin/build/subsites', 'system'));

  menu_link_save($link);

  // save css
  file_check_directory(file_create_path('subsites'), FILE_CREATE_DIRECTORY);
  file_check_directory(dirname(subsites_get_css_path($sid)), FILE_CREATE_DIRECTORY);
  file_save_data($css, subsites_get_css_path($sid), FILE_EXISTS_REPLACE);

  return $sid;
}
davyvdb’s picture

Status: Active » Fixed

Seems correct! I've fixed this in CVS.

jonline’s picture

Thanks :)

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

marcvangend’s picture

Davy, thanks for fixing this in CVS, but it took me a while to find this. Please consider to create a new release, or at least publish the nightly dev version.

davyvdb’s picture

Done ;)

marcvangend’s picture

Super, thanks!