0

カスタム テーマを 1 つのページに適用しようとしています。このページは、hook_menu を使用してセットアップしたものです。hook_theme を実装しましたが、Web サイトを更新すると、次のエラーが表示されます。

致命的なエラー: 行 1044 の /srv/bindings/baf029321aa248e5907866cc7de3a6d6/code/includes/form.inc でサポートされていないオペランドの種類

以下は私のコードです:

function mymodule_menu(){
    $items['mymodule'] = array(
        'title' => 'My-module',
        'page callback' => 'drupal_get_form',
        'page arguments' => array('mymodule_admin_page'),
        'access arguments' => array('access content'),
    );
    return $items;
}

function mymodule_admin_page(){
    drupal_set_message('My-module admin page responding');

    return theme('mymodule_template');
}

function mymodule_theme($existing, $type, $theme, $path){
    drupal_set_message('My-module theme hook responding');

    return array(
        'mymodule_template' => array(
            #'render element' => 'elements', 
            'template' => 'mytemplate',
            'path'  =>  drupal_get_path('module', 'mymodule') . '/templates',
        )
    ); 
}

私が知る限り、にスラッシュを追加するとエラーが発生し'path' => drupal_get_path('module', 'mymodule') . '/templates',ます。スラッシュを削除するとエラーは解消されますが、システムは mytemplate.tpl.php を探しているため、検索に失敗しますmymodule/templatemytemplate.tpl.php

4

1 に答える 1

0

これを試してください...このメニューは常にテーマ関数ではなくフォーム関数を呼び出します

$items['mymodule'] = array(
        'title' => 'My-module',
        'page callback' => 'drupal_get_form',//this is use a get the form
        'page arguments' => array('contactform_form'),// this is use a name of form 
        'access arguments' => array('access content'),
 );

function contactform_form($form, &$form_state)
{
     //write a form attributes
}
于 2014-04-12T05:29:55.790 に答える