我想得到我的野猫但我不能......
我在Hook_menu中的链接:
$items = array(); $items['tv8/channel/%'] = array( 'title' => 'Detail channel Tv8', 'description' => 'Détails d\'une chaîne Tv8', 'page callback' => 'tv8_program_channel_detail', 'access arguments' => array('access content'), 'page arguments' => array(1), 'type' => MENU_NORMAL_ITEM, ); return $items;我的链接定义如下:
"<a href='?q=tv8/channel/test'>" . $channel->name ."</a>" ,这里是我的回调函数:
function tv8_program_channel_detail($id) { $content_admin_panel = $id. "<div class='body'>" . "<ul class='admin-list'>" . "<li>" . "<div class='description'>" . "</div>" . "</li>" . "<li>" . "<div class='description'>" . "</div>" . "</li>" . "</ul>" . "</div>"; $content = array ( 'content' => array ( '#markup' => t($content_admin_panel), '#prefix' => '<div class="admin-panel">', '#suffix' => '</div>', ), ); return $content; }但是id返回“频道”而不是“测试”。
我想我做错了但是在drupal doc中找不到任何东西。
i want to get my wildcart but i cant...
my link in Hook_menu :
$items = array(); $items['tv8/channel/%'] = array( 'title' => 'Detail channel Tv8', 'description' => 'Détails d\'une chaîne Tv8', 'page callback' => 'tv8_program_channel_detail', 'access arguments' => array('access content'), 'page arguments' => array(1), 'type' => MENU_NORMAL_ITEM, ); return $items;my link is defined like that :
"<a href='?q=tv8/channel/test'>" . $channel->name ."</a>" ,and here my callback function :
function tv8_program_channel_detail($id) { $content_admin_panel = $id. "<div class='body'>" . "<ul class='admin-list'>" . "<li>" . "<div class='description'>" . "</div>" . "</li>" . "<li>" . "<div class='description'>" . "</div>" . "</li>" . "</ul>" . "</div>"; $content = array ( 'content' => array ( '#markup' => t($content_admin_panel), '#prefix' => '<div class="admin-panel">', '#suffix' => '</div>', ), ); return $content; }But id return "channel" and not "test".
I think i'm doing wrong but cant found anything in drupal doc.
最满意答案
在页面参数中,您需要将其更改为数组(2) 。 基于你的路径数组(0)加载'tv8',数组(1)加载'通道'和数组(2)加载参数%。 所以代码如下:
$items['tv8/channel/%'] = array( 'title' => 'Detail channel Tv8', 'description' => 'Détails d\'une chaîne Tv8', 'page callback' => 'tv8_program_channel_detail', 'access arguments' => array('access content'), 'page arguments' => array(2), 'type' => MENU_NORMAL_ITEM, );链接使用php函数l()也更好:
<?php print l($channel->name, 'tv8/channel/test'); ?>In page arguments you need change it to array(2). Based on your path array(0) load 'tv8', array(1) load 'channel' and array(2) load argument %. So code will be as follow:
$items['tv8/channel/%'] = array( 'title' => 'Detail channel Tv8', 'description' => 'Détails d\'une chaîne Tv8', 'page callback' => 'tv8_program_channel_detail', 'access arguments' => array('access content'), 'page arguments' => array(2), 'type' => MENU_NORMAL_ITEM, );Also better for link use php function l():
<?php print l($channel->name, 'tv8/channel/test'); ?>更多推荐
发布评论