toc

General questions about CMSimple
olape
Posts: 2731
Joined: Fri Mar 13, 2015 8:47 am
Contact:

Re: toc

Post by olape » Fri Aug 14, 2020 3:41 pm

But he may not always want the full sitemap, he just wants the one of the current branch.
I suppose. So an open submenu to the last level.
Gruß Olaf, Plugins for CMSimple_XH

Ich habe schon lange den Verdacht, dass so viele so eifrig auf Gender, Trans und Queer machen:
Weil sie für das Fachliche ganz einfach zu doof sind.

frase
Posts: 5085
Joined: Thu Apr 21, 2016 6:32 am
Location: Saxony
Contact:

Re: toc

Post by frase » Fri Aug 14, 2020 4:11 pm

By the way:
What ustalo is looking for, I could use right now.

One side.
A navigation at the top - only level 1 is displayed.
Below, a list of all subpages from exactly this page.
But (in my case) only the Level2 pages should be displayed. The Level3 and all other levels should be opened by a click (possibly animated).
Therefore all levels below Level2 should be available.
If you then click on a Level3 link, a page change can take place (also for Level2).
The opened page should then again show all sublevels of the corresponding Level1 page. Ideally also the corresponding opened menu.

This is quite tricky and I have failed so far.
For the time being I have to do without it.
A pity.

cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: toc

Post by cmb » Fri Aug 14, 2020 4:57 pm

lck wrote:
Fri Aug 14, 2020 12:12 pm
Keyword MyLi.
Not really. The responsibility of li() and XH\Li are to generate the properly nested <ul> structure for a menu, and to add the desired CSS classes. The pages which are part of that structure, have to be passed in; e.g. $hc contains all visible pages.

Anyhow, maybe you're looking for something like the following?

Code: Select all

<?php
function get_decendants(XH\Pages $pages, $page)
{
    $all = $children = $pages->children($page);
    foreach ($children as $child) {
        $grandchildren = get_decendants($pages, $child);
        $all = array_merge($all, $grandchildren);
    }
    return $all;
}
function open_submenu()
{
    global $s;

    if ($s < 0) return '';
    $pages = new XH\Pages;
    $descendants = array_unique(get_decendants($pages, $s), SORT_NUMERIC);
    sort($descendants, SORT_NUMERIC);
    return li($descendants, 'submenu');
}
?>
<nav><?=open_submenu()?></nav>
Christoph M. Becker – Plugins for CMSimple_XH

lck
Posts: 2963
Joined: Wed Mar 23, 2011 11:43 am
Contact:

Re: toc

Post by lck » Fri Aug 14, 2020 6:25 pm

cmb wrote:
Fri Aug 14, 2020 4:57 pm
Anyhow, maybe you're looking for something like the following?
👍🏻

... and put the code into userfuncs.php, you can also call the customized submenu in a page with

Code: Select all

{{{open_submenu();}}}
:)
„Bevor du den Pfeil der Wahrheit abschießt, tauche die Spitze in Honig!“   👉 Ludwig's XH-Templates for MultiPage & OnePage

olape
Posts: 2731
Joined: Fri Mar 13, 2015 8:47 am
Contact:

Re: toc

Post by olape » Fri Aug 14, 2020 6:27 pm

cmb wrote:
Fri Aug 14, 2020 4:57 pm
Anyhow, maybe you're looking for something like the following?

Code: Select all

<?php
function get_decendants(XH\Pages $pages, $page)
{
    $all = $children = $pages->children($page);
    foreach ($children as $child) {
        $grandchildren = get_decendants($pages, $child);
        $all = array_merge($all, $grandchildren);
    }
    return $all;
}
function open_submenu()
{
    global $s;

    if ($s < 0) return '';
    $pages = new XH\Pages;
    $descendants = array_unique(get_decendants($pages, $s), SORT_NUMERIC);
    sort($descendants, SORT_NUMERIC);
    return li($descendants, 'submenu');
}
?>
<nav><?=open_submenu()?></nav>
I think that's what's wanted.
I would just

Code: Select all

return li($descendants, 'submenu');
through

Code: Select all

return li($descendants, 'sitemaplevel');
replace.
Gruß Olaf, Plugins for CMSimple_XH

Ich habe schon lange den Verdacht, dass so viele so eifrig auf Gender, Trans und Queer machen:
Weil sie für das Fachliche ganz einfach zu doof sind.

frase
Posts: 5085
Joined: Thu Apr 21, 2016 6:32 am
Location: Saxony
Contact:

Re: toc

Post by frase » Fri Aug 14, 2020 6:28 pm

cmb wrote:
Fri Aug 14, 2020 4:57 pm
Anyhow, maybe you're looking for something like the following?
...
Wow!
That should already be largely what ustalo is looking for.
This can be done in the userfuncs.php, but also directly in the template.

Unfortunately, it still doesn't help me, because I need the whole menu below the L1 page in question.

ustalo
Posts: 164
Joined: Mon Aug 16, 2010 7:42 am
Location: Russia
Contact:

Re: toc

Post by ustalo » Fri Aug 14, 2020 6:34 pm

thx a lot
it is works
Aleksei

ustalo
Posts: 164
Joined: Mon Aug 16, 2010 7:42 am
Location: Russia
Contact:

Re: toc

Post by ustalo » Fri Aug 14, 2020 6:37 pm

and if put it on second level and expand levels 3, 4?
Aleksei

cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: toc

Post by cmb » Fri Aug 14, 2020 9:43 pm

ustalo wrote:
Fri Aug 14, 2020 6:37 pm
and if put it on second level and expand levels 3, 4?
I think that should already work. :?
frase wrote:
Fri Aug 14, 2020 6:28 pm
Unfortunately, it still doesn't help me, because I need the whole menu below the L1 page in question.


Um, I don't quite understand. As it is now (or more precisely, how it is supposed to be now), open_submenu() should display links to all subpages (and sub-subpages etc.).
Christoph M. Becker – Plugins for CMSimple_XH

frase
Posts: 5085
Joined: Thu Apr 21, 2016 6:32 am
Location: Saxony
Contact:

Re: toc

Post by frase » Sat Aug 15, 2020 7:01 am

cmb wrote:
Fri Aug 14, 2020 9:43 pm
Um, I don't quite understand. As it is now (or more precisely, how it is supposed to be now), open_submenu() should display links to all subpages (and sub-subpages etc.).
Ja, Aleksei (ustalo) dürfte sehr zufrieden sein mit deinem Code. Einfach genial.

Mein Anliegen war etwas anders gelagert. (Ich schreibe weiter in Deutsch, weil es ja eigentlich ein anderes Thema ist und ich mich vielleicht vertändlicher ausdrücken kann.)

open_submenu() zeigt alle Unter- und Unter-Seiten an.
Ich benötige hingegen immer den gesamten Menüzweig (ab L2) unterhalb einer L1-Seite, egal ob man sich auf einer L2, L3 ... Seite befindet.
Außerdem muss die aktuell geöffnete Seite im Menü mindestens markiert sein, damit ersichtlich ist wo man sich in dem Zweig befindet.
Geplant war, alle Unterseiten >L2 einzuklappen und nur den aktuellen Zweig zu öffnen. Die anderen müssen aber vorhanden sein, damit man sie per Klick öffnen (aufklappen) kann.

Das soll also ähnlich funktionieren, wie das Menü in fhs_adminmenu - nur eben mit allen Menüpunkten unterhalb einer L1-Seite. Im Idealfall sollte eben auch der aktuelle Zweig bei Aufruf geöffnet sein und die aktuelle Seite hervorgehoben.

Post Reply