在rails中,如何显示当前用户访问过的最近5页的列表?
我知道我可以执行redirect_to(request.referer)或redirect_to(:back)链接到最后一页,但是如何创建实际的页面历史列表?
它主要用于原型,所以我们不必将历史存储在db中.会议将做.
我想创建一个包含来自page.tpl.php的$ tabs的块
/**
* Implements hook_block_info().
*/
function mymodule_block_info() {
$blocks['tabs'] = array(
'info' => t('Tabs in block'),
'description' => t('blah blah blah'),
);
return $blocks;
}
/**
* Implements hook_block_view().
*/
function mymodule_block_view($delta = '') {
$block = array();
switch ($delta) {
case 'tabs':
$block['subject'] = t("THIS IS ZHE TABS!");
$block['content'] = array(
'#theme' => 'menu_local_tasks',
'#primary' => menu_local_tasks(0),
'#secondary' => menu_local_tasks(1),
);
break;
}
return $block;
}
Run Code Online (Sandbox Code Playgroud)
该块正在正确注册,并且正在显示正确的选项卡.但是,Drupal会抛出很多错误!
Warning: Invalid argument supplied for foreach() in element_children() (line 6300 …Run Code Online (Sandbox Code Playgroud) 我想实现这个目标:

要么

优选仅在css中.
我四处搜索并阅读了这篇文章http://css-tricks.com/fluid-width-equal-height-columns/.然而,它并没有真正解决溢出容器问题的背景颜色.
与使用多个 if else 相比,我真的很喜欢 switch 语句的结构。然而有时我想使用 switch 语句并在多种情况下具有相同的值。这可以以某种方式完成吗?
switch($fruit) {
case 'apple':
case 'orange':
// do something for both apples and oranges
break;
case: 'apple':
// do something for only apples
break;
case: 'orange':
// do something for only oranges
break;
}
Run Code Online (Sandbox Code Playgroud)
我希望我的例子表明我打算做什么......
我有一个未知长度的数组:
$array = array('1', '2', '3', '4', '5', '6', '7', '8' ...);
Run Code Online (Sandbox Code Playgroud)
我需要将此数组输出为多个列表,其中为每3个数组条目创建一个新列表.
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
</ul>
<ul>
<li>4</li>
<li>5</li>
<li>6</li>
</ul>
<ul>
<li>7</li>
<li>8</li>
</ul>
Run Code Online (Sandbox Code Playgroud)
请注意,即使它不包含3个列表项,我也需要关闭最后一个列表.
这是我的尝试:
<?php for ($i = 0; $i < count($rows); ++$i): ?>
<?php if (($i % 3) == 0): ?>
<ul>
<?php endif; ?>
<li><?php print $rows[$i]; ?></li>
<?php if (($i % 3) == 2): ?>
</ul>
<?php endif; ?>
<?php endfor; ?>
Run Code Online (Sandbox Code Playgroud) 我有两个数组:
$array1 = array(
'currencies' => array(
'dollars' => array(80,120,75),
'euro' => array(25,35,10,85),
),
);
$array2 = array(
'currencies' => array(
'dollars' => array(25),
),
);
Run Code Online (Sandbox Code Playgroud)
我希望结果如下:
$result = array(
'currencies' => array(
'dollars' => array(80,120,75,25),
'euro' => array(25,35,10,85),
),
);
Run Code Online (Sandbox Code Playgroud)
这可以巧妙地完成吗?我试过了array_merge,array_merge_recursively等.