Hi everyone!

I tried to use the example (node_example.module V5.x) to create a custom node type. I also used an *.install file to create my tables.
The install file works fine - I actually cannot test if the uninstall works, more on that later.

after installing my custom module (right after clicking the Save Config on 'Administe'>'Site building'>"Modules') the following output is shown:

  * Installing phasma
  * Phasma module installed tables successfully.
  * The content fields table content_type_embedded has been created.
  * The configuration options have been saved.

  Array

So somehow the list of modules does not appear ?!? (it is replaced by Array)

I can see that 'my' tables has been created and also a custom content type (table: content_type_embedded). When I try to add a node of the 'embedded' type. the following message is shown:
Illegal offset type in isset or empty in /var/www/html/content/modules/node/node.module on line 244.

When I return to the modules page all I get is:
Array (After Modules are plugins for Drupal.............on the administration by module page.)

Can anybody tell me what I am doing wrong?

Thnx

Comments

styro’s picture

you will probably need to list your module for anyone to figure out what you are doing wrong.

--
Anton
New to Drupal? | Troubleshooting FAQ
Example knowledge base built with Drupal

trisooma’s picture

  • phasma.info
name = Phasma
description = The phasma module does some very nice things.
package = Phasma
version = "5.x"
project = "phasma"
datestamp = "1216337527"
  • phasma.install
  • <?php
    
    function phasma_install() {
      drupal_set_message('Installing phasma');
      switch ($GLOBALS['db_type']) {
        case 'mysqli':
        case 'mysql':
          db_query("CREATE TABLE if not exists {phasma} (
            vid int(10) unsigned NOT NULL default '0',
            nid int(10) unsigned NOT NULL default '0',
            reference varchar(200) NOT NULL UNIQUE,
            description varchar(255),
            -- authentication
            auth_type int(1) unsigned NOT NULL default '0',		-- 1:none, 2:jinzora, 3:torrentflux
            auth_usertype int(1) unsigned NOT NULL default '0',	-- 1:none, 2:loggedin, 3:specified
            auth_user varchar(100),
            auth_pass varchar(100),
            PRIMARY KEY (vid, nid)
          )");
          $success = TRUE;
          break;
    
        case 'pgsql':
          $success = FALSE;
          break;
      } // End case
    
      if ($success) {
        drupal_set_message(t('Phasma module installed tables successfully.'));
      }
      else {
        drupal_set_message(t('The installation of phasma module was not successful.'), t('pgsql not supported'));
      }
    }
    
    function phasma_uninstall() {
      if (db_table_exists('phasma')) {
        db_query("DROP TABLE {phasma}");
      }
    }
    
  • phasma.module
  • <?php
    
    function phasma_node_info() {
      return array(
        'embedded' => array(
          'name' => t('Embedded node'),
          'module' => 'phasma',
          'description' => t('This node implements an embedded URL.'),
          'has_body' => FALSE,
          'locked' => TRUE
        )
      );
    }
    
    function phasma_perm() {
      return array( 'create phasma node', 'edit own phasma nodes' );
    }
    
    function phasma_access( $op, $node ) {
      global $user;
    
      if( $op == 'create' ) {
        // Only users with permission to do so may create this node type.
        return user_access( 'create phasma node' );
      }
    
      // Users who create a node may edit or delete it later, assuming they have the
      // necessary permissions.
      if( $op == 'update' || $op == 'delete' ) {
        if( user_access( 'edit own phasma nodes' ) && ($user->uid == $node->uid) ) {
          return TRUE;
        }
      }
    }
    
    function phasma_form( &$node ) {
      $type = node_get_types( 'type', $node );
    
      // base
      $form['title'] = array(
        '#type' => 'textfield',
        '#title' => check_plain( $type->title_label ),
        '#required' => TRUE,
        '#default_value' => $node->title,
        '#weight' => -5,
      );
    
      $form['bf']['body'] = array(
        '#type' => 'textarea',
        '#title' => check_plain( $type->body_label ),
        '#default_value' => $node->body,
        '#required' => FALSE,
      );
      $form['bf']['filter'] = filter_form( $node->format );
    
      // custom
      $form['reference'] = array(
        '#type' => 'textfield',
        '#title' => 'URL',
        '#default_value' => $node->reference,
        '#required' => TRUE,
        '#size' => 40,
        '#maxlength' => 200,
      );
      $form['auth_type'] = array(
        '#type' => 'select',
        '#title' => 'Auth Type',
        '#default_value' => $node->auth_type,
        '#options' => array(
          1 => 'None',
          2 => 'Jinzora',
          3 => 'TorrentFlux',
        ),
        '#required' => TRUE,
        '#description' => 'Please choose an authentication type.',
      );
      $form['auth_usertype'] = array(
        '#type' => 'select',
        '#title' => 'Auth User Type',
        '#default_value' => $node->auth_usertype,
        '#options' => array(
          1 => 'None',
          2 => 'Logged in user',
          3 => 'Specified',
        ),
        '#required' => TRUE,
        '#description' => 'Please choose an authentication user.',
      );
      $form['auth_user'] = array(
        '#type' => 'textfield',
        '#title' => 'Username',
        '#default_value' => $node->auth_user,
        '#required' => FALSE,
        '#size' => 20,
        '#maxlength' => 100,
      );
      $form['auth_pass'] = array(
        '#type' => 'textfield',
        '#title' => 'Password',
        '#default_value' => $node->auth_pass,
        '#required' => FALSE,
        '#size' => 20,
        '#maxlength' => 100,
      );
    
      return $form;
    }
    
    function phasma_validate( &$node ) {
      if( $node->auth_type == '0' ) {
        form_set_error( 'auth_type', 'The authentication type must specified.' );
      }
      if( $node->auth_usertype == '0' ) {
        form_set_error( 'auth_usertype', 'The authentication user must specified.' );
      }
      if( $node->auth_type == '1' && $node->auth_usertype == '1' ) {
        if( strlen( trim( $node->auth_user )) > 0 ) {
          form_set_error( 'auth_user', 'Username cannot be set for AuthType:none, AuthUserType:none.' );
        }
        if( strlen( trim( $node->auth_pass )) > 0 ) {
          form_set_error( 'auth_user', 'Username cannot be set for AuthType:none, AuthUserType:none.' );
        }
      }
      // should be checked further
    }
    
    function phasma_insert($node) {
      db_query( "INSERT INTO {phasma} (vid, nid, reference, auth_type, auth_usertype, auth_user, auth_pass) VALUES (%d, %d, '%s', %d, %d, '%s', '%s')", $node->vid, $node->nid, $node->reference, $node->auth_type, $node->auth_usertype, $node->auth_user, $node->auth_pass );
    }
    
    function phasma_update($node) {
      // is this a new node or are we adding a new revision
    
      if($node->revision ) {
        phasma_insert( $node );
      }
      else {
        db_query( "UPDATE {phasma} SET reference='%s', auth_type=%d, auth_usertype=%d, auth_user='%s', auth_pass='%s' WHERE vid=%d", $node->reference, $node->auth_type, $node->auth_usertype, $node->auth_user, $node->auth_pass, $node->vid );
      }
    }
    
    /**
     * Implementation of hook_nodeapi().
     *
     * When a node revision is deleted, we need to remove the corresponding record
     * from our table. The only way to handle revision deletion is by implementing
     * hook_nodeapi().
     */
    function phasma_nodeapi( &$node, $op, $teaser, $page ) {
      switch( $op ) {
        case 'delete revision':
          // Notice that we're matching a single revision based on the node's vid.
          db_query( 'DELETE FROM {phasma} WHERE vid = %d', $node->vid );
          break;
      }
    }
    
    function phasma_delete( $node ) {
      // match by node's nid (all revs)
      db_query( 'DELETE FROM {phasma} WHERE nid = %d', $node->nid );
    }
    
    function phasma_load( $node ) {
      $additions = db_fetch_object( db_query( 'SELECT reference, auth_type, auth_usertype, auth_user, auth_pass FROM {phasma} WHERE vid = %d', $node->vid ));
      return $additions;
    }
    
    function phasma_view( $node, $teaser = FALSE, $page = FALSE ) {
      $node = node_prepare( $node, $teaser );
      $node->content['myfield'] = array(
        '#value' => theme( 'phasma_embed', $node ),
        '#weight' => 1,
      );
      return $node;
    }
    
    function theme_phasma_embed( $node ) {
      $output = '<div class="embedded">';
      $output .= '<iframe style="width: 100%; height: 100%; border: none;" src="'.$node->reference.'"></iframe>';
      $output .= '</div>';
      return $output;
    }
    
    trisooma’s picture

    Anyone?

    jwilson3’s picture

    I know this is late, but im also in the process of learning/writing my first big custom node module, so decided to try yours out.

    Upon enabling the module you posted from a clean drupal install I got no problems. Two thoughts:

    * Perhaps another module is conflicting or
    * Your seeing the problem as a result of a previous uninstall that didn't get rid of everything created by the module and subsequent reinstall?

    I tried uninstall and reinstall various times and never got your error.