вот код модуля
// $Id$
function ahah_goods_filter_help($path, $arg)
{
}
function ahah_goods_filter_perm()
{
return array('access ahah_goods_filter content');
}
function ahah_goods_filter_menu()
{
$items['filter/%'] = array(
'title' => t('My page'),
'callback' => 'ahah_goods_filter_processor',
'access arguments' => array('access filter content'),
'type' => MENU_CALLBACK
);
return $items;
}
function ahah_goods_filter_processor()
{
return drupal_json(array('status' => TRUE, 'data' => "Hello Drupal World"));
}
function ahah_goods_filter_form()
{
// Тут будет строится форма фильтра с учётом языка и тд.
$form['name'] = array(
'#type' => 'textfield',
'#title' => t('Name'),
'#size' => 30,
'#maxlength' => 64,
'#description' => t('Enter the name for this group of settings'),
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Submit'),
'#weight' => 1,
'#submit' => array('my_form_submit'),//none JS version
'#ahah' => array(
'event' => 'click',
'path' => 'filter/',
'wrapper' => 'myform-wrapper',
'method' => 'replace',
'effect' => 'fade',
'progress' => array(
'type' => 'bar',
'message' => t('Loading...')
)
)
);
return $form;
}
// Собственно - блок фильтра. В нём будет форма
function ahah_goods_filter_block($op='list', $delta=0)
{
if ($op == "list")
{
$block[0]["info"] = t('Romsat goods filter');
return $block;
}
elseif($op == 'view')
{
$block['subject'] = 'Romsat FILTER';
$block['content'] = drupal_get_form('ahah_goods_filter_form');
return $block;
}
}
При нажатии кнопки вылетает ошибка 404. Не могу понять почему путь не зарегистрирован в системе. Кэш чистил, всё делал. Ничего не помогло
Комментарии
У вас в коде не только эта ошибка, остальные, видимо, позже выползут
Аргумент то вам зачем?
$items['filter/%']
оставьте здесь только filter.Начните с проверки того, выводиться ли что-либо по адресу site.com/filters
что-то я с правами никак не разберусь... всё время выдаёт 403 ошибку.
вот крайний вариант прав
return array('access ahah_goods_filter');
} // function newmodule_perm
function ahah_goods_filter_menu()
{
$items['ahah_goods_filter'] = array(
'title' => t('My page'),
'callback' => 'ahah_goods_filter_processor',
'access arguments' => array('access content'),
'type' => MENU_CALLBACK
);
return $items;
}
function ahah_goods_filter_processor()
{
firep("OK");
return drupal_json(array('status' => TRUE, 'data' => "Hello Drupal World"));
}