Issue Feature Closed

#17650option end for HMENU / and negative values for begin and end

Daniel Poetzinger 10/04/07, 16:46 updated 09/06/13, 09:22

Description

For special requirements we needed something like:

1=HMENU
1 {
end=-1
begin=-2
..
}

So we needed to adjust tslib_menu to allow:
  • the parameter end to configure a endpoint
  • allow negative values for begin and end, so you can define a offset from the end of the menuitems

I provide a patch later. Here is the new code for function makeMenu

$begin = tslib_cObj::calc($this->mconf[‘begin’] ? $this->mconf[‘begin’] : $this->conf[‘begin’]);
$endat = tslib_cObj::calc($this->mconf[‘end’] ? $this->mconf[‘end’] : $this->conf[‘end’]);

$banUidArray = $this->getBannedUids();
    // Fill in the menuArr with elements that should go into the menu:
$this->menuArr = Array();
foreach($temp as $data) {
$spacer = (t3lib_div::inList($this->spacerIDList,$data[‘doktype’]) || !strcmp($data[‘ITEM_STATE’],‘SPC’)) ? 1 : 0; // if item is a spacer, $spacer is set
if ($this->filterMenuPages($data, $banUidArray, $spacer)) {
$c_b++;
if ($begin<=$c_b) { // If the beginning item has been reached.
$this->menuArr[$c] = $data;
$this->menuArr[$c][‘isSpacer’] = $spacer;
$c++;
if ($maxItems && $c>=$maxItems) {
break;
}
}
if ($endat>0 && $endat<=$c_b) {
break;
}
}
}
//delete last items if endat is negative
if ($endat<0) {
$_end=$c+$endat;
if ($_end<0)
$_end=0;
for ($i=$c;$i>=$_end; $i—) {
unset($this->menuArr[$i]);
}
}
//delete the first items if begin was negative
if ($begin<0) {
$_begin=$c+$begin;
if ($_begin<0)
$_begin=0;
for ($i=0; $i<$_begin; $i++) {
array_shift($this->menuArr);
}
}

(issue imported from #M6452)

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.