[英]hook_menu not working for me, neither helloworld example
我整天都在使用drupal 7 hook_menu進行戰斗,而幾天前,當我創建新模塊,新菜單項等時,一切都在工作。
我正在開發一個cron,取決於1個參數,它會生成一個文件以輸出,或讀取其他文件(輸入)。
我試圖定義一個簡單的URL來測試cron,當我將... lec_profile_cron放入Brosers中時,它可以工作,但是如果嘗試.... companies_cron / 1或其他公司的y名稱放在$ items ['路線”],它不起作用。
我試圖清理緩存,memcached,使用drush rr,全部,不了解發生了什么。
我在我創建的名為helloworld的新模塊中嘗試了很多組合和示例,例如helloword_hello菜單選項,但未找到其返回404。
// CRON TEST
$items['companies_cron/%out'] = array(
'title' => t('Test cron'),
'page callback' => 'lec_profile_cron',
'page arguments' => array(1),
'access arguments' => array('administer lec profile configuration')
);
function lec_profile_cron($out)
{
// CRON OUT
if ($out == 1) {
//do stuff
} else {
//CRON IN
}
}
也許是愚蠢的事情,但我找不到...
提建議。
根據文檔,我認為這會更好。 您不需要在$ items中使用%out來獲取args,而且我還認為您錯過了我添加的“訪問參數”的末尾逗號,並且還返回了一些內容。
$items['companies_cron'] = array(
'title' => t('Test cron'),
'page callback' => 'lec_profile_cron',
'page arguments' => array(1),
'access arguments' => array('administer lec profile configuration'),
return $items;
);
function lec_profile_cron($out = 0){
// If companies_cron/ is called, $out takes default value of 0
// If companies_cron/1 is called, $out value will be 1
// To pass multiple args, like companies_cron/1/2, you would require further params with defaults like $out = 0, $in = 0 ...
// CRON OUT
if ($out == 1) {
//do stuff
} else {
//CRON IN
}
};
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.