Hi the experts
I have several hidden pages on level 3 and would like to show these pages in the menu, if selected. Unfortunately, if parent page on level 2 is also hidden, this parent level page will not appear in the menu. In my fold-out menu, if the parent level doesn't show up, nothing will be shown.
I just would like a little trick to make hidden parentpages also show up in the menu, if a hidden subpage is selected.
Any idea?
Show_hidden not showing levels in between
Re: Show_hidden not showing levels in between
Hm, the current behavior might be regarded as bug.
Anyway, in your case you need a customized $hc, I presume. Currently we have the following in cmsimple/cms.php:
The relevant line is the longest; there has to be a third or-clause:
(The code could be somewhat simplified.) As there is no function parentOf($index), you have to define one. The simplest solution is to make use of XH_Pages (available since XH 1.6) and to ignore recursion issues (not needed in your case):
Inlining the code would be more efficient, though.
Anyway, in your case you need a customized $hc, I presume. Currently we have the following in cmsimple/cms.php:
Code: Select all
// Compatibility for DHTML menus
$si = -1;
$hc = array();
for ($i = 0; $i < $cl; $i++) {
if (!hide($i) || ($i == $s && $cf['show_hidden']['pages_toc'] == 'true')) {
$hc[] = $i;
}
if ($i == $s) {
$si = count($hc);
}
}
$hl = count($hc);
Code: Select all
if (!hide($i) || ($i == parentOf($s) && $cf['show_hidden']['pages_toc'] == 'true') || ($i == $s && $cf['show_hidden']['pages_toc'] == 'true')) {
Code: Select all
function parentOf($index)
{
global $pth;
include_once $pth['folder']['classes'] . 'Pages.php';
$pages = new XH_Pages();
return $pages->parent($index);
}
Christoph M. Becker – Plugins for CMSimple_XH
Re: Show_hidden not showing levels in between
I've put in on the roadmap.cmb wrote:the current behavior might be regarded as bug
However unfortunately your code doesn't seem to do the job, at least not here. (Changed the respective line in cms.php and added the function to functions.php.) Breadcrumbs actually worked correctly with show_hidden even before.
My menu:
Code: Select all
<ul class="menulevel1">
<li class="docs"><a href="/Svasti/?Start">Start</a></li>
<li class="docs"><a href="/Svasti/?Templates_%28Designs%29">Templates (Designs)</a></li>
<li class="docs"><a href="/Svasti/?Kurzanleitung">Kurzanleitung</a>
<ul class="menulevel2">
<ul class="menulevel3">
<li class="sdoc"><span>Miniblog</span></li>
</ul>
</ul>
</li>
</ul>
Re: Show_hidden not showing levels in between
I had overlooked the $ignoreHidden parameter of XH_Pages::parent(). The following should work:svasti wrote:The hidden parents of Miniblog are still missing.
Code: Select all
function parentOf($index)
{
global $pth;
include_once $pth['folder']['classes'] . 'Pages.php';
$pages = new XH_Pages();
return $pages->parent($index, false);
}
Christoph M. Becker – Plugins for CMSimple_XH
Re: Show_hidden not showing levels in between
I my special case also the parent of the parent is hidden. Unfortunately this most important grandparent is still missing.
Re: Show_hidden not showing levels in between
Well, then the following will do (although somewhat inefficently):
In cmsimple/cms.php:
Code: Select all
/**
* @return array<int>
*/
function ancestorsOf($index)
{
global $pth;
include_once $pth['folder']['classes'] . 'Pages.php';
$pages = new XH_Pages();
$result = array();
while (true) {
$parent = $pages->parent($index, false);
if ($parent === null) {
break;
}
$result[] = $parent;
$index = $parent;
}
return $result;
}
Code: Select all
if (!hide($i)
|| $cf['show_hidden']['pages_toc'] == 'true'
&& ($i == $s || in_array($i, ancestorsOf($s)))
) {
$hc[] = $i;
}
Christoph M. Becker – Plugins for CMSimple_XH
Re: Show_hidden not showing levels in between
Yep, works, thanx.