mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Fix getCrumbs() with no crumbs and first link.
Apply patch from 'Andy Hobbs' to fix issues with breadcrumbs, and a starting breadcrumb. Fixes #2689
This commit is contained in:
parent
d0733ceb00
commit
c54ac257f1
2 changed files with 16 additions and 4 deletions
|
@ -1161,6 +1161,18 @@ class HtmlHelperTest extends CakeTestCase {
|
||||||
* Test the array form of $startText
|
* Test the array form of $startText
|
||||||
*/
|
*/
|
||||||
public function testGetCrumbFirstLink() {
|
public function testGetCrumbFirstLink() {
|
||||||
|
$result = $this->Html->getCrumbList(null, 'Home');
|
||||||
|
$this->assertTags(
|
||||||
|
$result,
|
||||||
|
array(
|
||||||
|
'<ul',
|
||||||
|
array('li' => array('class' => 'first')),
|
||||||
|
array('a' => array('href' => '/')), 'Home', '/a',
|
||||||
|
'/li',
|
||||||
|
'/ul'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
$this->Html->addCrumb('First', '#first');
|
$this->Html->addCrumb('First', '#first');
|
||||||
$this->Html->addCrumb('Second', '#second');
|
$this->Html->addCrumb('Second', '#second');
|
||||||
|
|
||||||
|
|
|
@ -671,9 +671,9 @@ class HtmlHelper extends AppHelper {
|
||||||
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/html.html#creating-breadcrumb-trails-with-htmlhelper
|
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/html.html#creating-breadcrumb-trails-with-htmlhelper
|
||||||
*/
|
*/
|
||||||
public function getCrumbs($separator = '»', $startText = false) {
|
public function getCrumbs($separator = '»', $startText = false) {
|
||||||
if (!empty($this->_crumbs)) {
|
$crumbs = $this->_prepareCrumbs($startText);
|
||||||
|
if (!empty($crumbs)) {
|
||||||
$out = array();
|
$out = array();
|
||||||
$crumbs = $this->_prepareCrumbs($startText);
|
|
||||||
foreach ($crumbs as $crumb) {
|
foreach ($crumbs as $crumb) {
|
||||||
if (!empty($crumb[1])) {
|
if (!empty($crumb[1])) {
|
||||||
$out[] = $this->link($crumb[0], $crumb[1], $crumb[2]);
|
$out[] = $this->link($crumb[0], $crumb[1], $crumb[2]);
|
||||||
|
@ -701,9 +701,9 @@ class HtmlHelper extends AppHelper {
|
||||||
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/html.html#creating-breadcrumb-trails-with-htmlhelper
|
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/html.html#creating-breadcrumb-trails-with-htmlhelper
|
||||||
*/
|
*/
|
||||||
public function getCrumbList($options = array(), $startText = false) {
|
public function getCrumbList($options = array(), $startText = false) {
|
||||||
if (!empty($this->_crumbs)) {
|
$crumbs = $this->_prepareCrumbs($startText);
|
||||||
|
if (!empty($crumbs)) {
|
||||||
$result = '';
|
$result = '';
|
||||||
$crumbs = $this->_prepareCrumbs($startText);
|
|
||||||
$crumbCount = count($crumbs);
|
$crumbCount = count($crumbs);
|
||||||
$ulOptions = $options;
|
$ulOptions = $options;
|
||||||
foreach ($crumbs as $which => $crumb) {
|
foreach ($crumbs as $which => $crumb) {
|
||||||
|
|
Loading…
Reference in a new issue