Drupal 7 Drupal7传递多个字段
如何通过Drupal 7 Drupal7传递多个字段,drupal-7,field,Drupal 7,Field,如何通过$data传递多个字段值,并使用$items呈现它们 请参阅下面的代码片段: function custom_block_view($delta = '') { global $user; $account = $user; $block['content'] = t('Hello @user from IP @host',array( '@user' => format_username($user), '@host' => $account->hostname ))
$data
传递多个字段值,并使用$items
呈现它们
请参阅下面的代码片段:
function custom_block_view($delta = '') {
global $user;
$account = $user;
$block['content'] = t('Hello @user from IP @host',array(
'@user' => format_username($user),
'@host' => $account->hostname
));
$result = db_select('node','a')
->fields('a', array('title', 'nid', 'status'))
->execute();
foreach($result as $node) {
$items[] = array(
'data' => t($node->title)
);
}
$block['content'] .= theme('item_list', array(
'items' => $items
));
return $block;
}
我找到了如何通过
$data
传递另一个值的方法。只需添加一个简单的连接符号(.)
请检查下面的代码片段
foreach($result as $node) {
$items[] = array(
'data' => t($node->title).t($node->nid)
);
}
只能使用包含呈现HTML内容的可呈现数组或字符串 内容:块体的内容。这可能是一个可渲染数组(首选)或一个字符串,其中包含呈现的HTML内容 有关详细信息,请参阅此链接: 改变 块和页面都可以更改,就像表单已经更改了一段时间一样。许多其他类型也可以更改。使用hook_page_alter()我们可以执行以下操作:
function mymodule_page_alter(&$page) {
// Move search form into the footer.
$page['footer']['search_form'] = $page['sidebar_first']['search_form'];
unset($page['sidebar_first']['search_form']);
// Remove the "powered by Drupal" block
unset($page['footer']['system_powered-by']);
}