Domanda

Sto cercando di creare un semplice modulo in Drupal 6.20 come segue:

<?php

function example_help($section) {
  switch ($section) {
    case 'admin/modules#description':
      return t('This module implements an example form.');
  }
}

function example_menu($may_cache) {
  $items = array();
  if ($may_cache) 
  {
    $items[] = array(
      'path' => 'example',
      'title' => t('Example'),
      'callback' => 'example_page',
      'access' => TRUE,
      'type' => MENU_NORMAL_ITEM
    );
  }
  return $items;
}

function example_page() {
  return drupal_get_form('example_page_form');
}

function example_page_form() {
  $form['fullname'] = array(
    '#type' => 'textfield',
    '#title' => t('Enter your full name'),
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save'),
  );
  return $form;
}

function example_page_form_submit($form_id, $form_values) {
  ...some code
}

Ma ogni volta che sto scrivendo in http://mysite.com/example , la sua sempre reindirizzato a 404. Per favore aiuto. Sono molto nuovo alla tecnologia Drupal. C'è ne più file necessari per questa parte il .info e file di .module?

Grazie.

È stato utile?

Soluzione

Ive ha ottenuto la soluzione. Per Drupal 6.X è gancio menù dovrebbe essere la seguente:

function example_menu() {
  $items = array();
    $items['example'] = array(
        'title' => 'List',
        'page callback' => 'example_page',
        'access callback' => 'user_access',
        'access arguments' => array('access content'),
        'weight' => -10,
        'type' => MENU_DEFAULT_LOCAL_TASK,
      );
  return $items;
}
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top