Добрый всем день, целый день бьюсь об стену и не могу получить ничего, вообще ничего.
Ситуация такая. Создаю первый модуль, для начала нужно просто helloWORLD написать бы.
Последние варианты которые пробовал - это
<?php
function mymodule_menu($may_cache) {
$items = array();
if ($may_cache) {
$items[] = array(
'path' => 'mypage',
'title' => t('My page'),
'callback' => '_my_page',
'type' => MENU_NORMAL_ITEM
);
}
return $items;
}
function
_my_page() {
return '<strong>Hello, world!</strong>';
}
?>
и
<?php
/**
* Generate HTML for the onthisdate block
* param op the operation from the URL
* param delta offset
* returns block HTML
*/
function onthisdate_block($op='list', $delta=0, $edit = array()) {
// listing of blocks, such as on the admin/block page
switch($op){
case
"list":
$block[0]["info"] = t("On This Date");
return $block;
break;
case "view":
// our block content
// content variable that will be returned for display
$block_content = '';
// Get today's date
$today = getdate();
// calculate midnight one week ago
$start_time = mktime(0, 0, 0,$today['mon'],
($today['mday'] - 7), $today['year']);
// we want items that occur only on the day in question, so
//calculate 1 day
$end_time = $start_time + 86400;
// 60 * 60 * 24 = 86400 seconds in a day
$limitnum = variable_get("onthisdate_maxdisp", 3);
$query = "SELECT nid, title, created FROM {node}" .
"{node} WHERE created >= %d " .
"AND created <= %d";
$queryResult = db_query_range($query, $start_time, $end_time, 0, $limitnum);
while (
$links = db_fetch_object($queryResult)) {
$block_content .= l($links->title, 'node/'.$links->nid) . '<br />';
}
// check to see if there was any content before setting up the block
if ($block_content == '') {
// no content from a week ago, return nothing.
return;
}
// set up the block
$block['subject'] = 'On This Date';
$block['content'] = $block_content;
return $block;
break;
case
"configure":
// Compile a list of fields to show
$form['onthisdate_maxdisp'] = array(
'#type' => 'textfield',
'#title' => t('Maximum number of links'),
'#default_value' => variable_get('onthisdate_maxdisp', 3),
'#size' => 2,
'#maxlength' => 2,
'#description' => t("The maximum number of links to display in the block.")
);
return $form;
// for some reason the core modules don't insert a break after the "configure" case
case "save":
variable_set('onthisdate_maxdisp', $edit['onthisdate_maxdisp']);
break;
}
}
?>
Ну и естественно к ним файлы info, приблизательно вот с таким содержанием:
<?php; $Id$
name = Prognoz
description = Module by created sports prognoz
package = sport
version = 1.0
core = 6.x?>
Сохраняю эти файлы в одноименные папки ../sites/all/modules/..
Делаю в Notepad++, кодировку выбираю UTF без BOM.
Включаю модули на странице http://drupal/admin/build/modules
Но на странице http://drupal/mypage и на http://drupal/?q=mypage, получаю "Страница не найдена",делаю на локалхосте как видно из адреса.
Укажите пожалуйста мне на ошибку. Уже голова взрывается. спасибо всем откликнушемся.
PS. Тех кто не может помочь, а желает показать свою "значимость", просьба проходить мимо. Если у кого то есть желание пообщатся по аське, то милости прошу - 321016583
Комментарии
$items = array();
$items['hello'] = array( // http://mysite.ru/hello
'title' => 'Hello world',
'page callback' => 'mymodule_hello_world',
'type' => MENU_CALLBACK,
);
return $items;
}
function mymodule_hello_world() {
return '<h1>Hello world!!!</h1>';
}
А вообще смотрите api
Попробовал засунуть твой код в модуль, история та же, страница не найдена... просто руки опускаются, мне щас главное запустить хоть что нибудь, а потом начтну экспиреминтировать с этим добром. кто еще чем может помочь ?
Код, который дал Guide правильный. Чтобы заработало, нужно очистить кеш друпала.