Closed raiserle closed 4 years ago
How should I reproduce this? Which syntax do you use? what are pagenames, what are page titles? is numbering manually? or by plugin?
The numbering is done by Numbering Headlines
plugin.
The page names are not the headline.
The menu is generated by headlines shown in the example:
A1. Appendix << 1st Headline [Site name: osite]
I want the menu to be sorted first by numbers, then by letters. From 1 to A, not from A to 9.
Have I sufficiently explained this time? Sorry.
regards raiserle
This helps indeed, thanks. I have not yet experience with the Numbering Headlines plugin. So for now I have not a quick answer.
Quick suggestion:
Sort by the title of the page. The HEADLINE plugin is automatically covered.
Detail from the DEBUG, how you build up the menu. ./lib/plugins/indexmenu/syntax/indexmenu.php (407): print_r($data); -->
Array
(
[0] => Array
(
[id] => administration
[type] => d
[level] => 1
[open] => 1
[title] => A1. Administration
[hns] => administration:administration
[file] => //administration
[return] => 1
[sort] => 0
)
[1] => Array
(
[id] => administration:artikeleinstellungen
[type] => f
[level] => 2
[open] =>
[title] => A1.2 Artikeleinstellungen
[hns] =>
[file] => //administration/artikeleinstellungen.txt
[return] => 1
[sort] => artikeleinstellungen
)
[2] => Array
(
[id] => administration:epis
[type] => f
[level] => 2
[open] =>
[title] => A1.1 EPIS Menüleiste
[hns] =>
[file] => //administration/epis.txt
[return] => 1
[sort] => epis
)
[3] => Array
(
[id] => eplan_softwarebeschreibung_allgemein
[type] => d
[level] => 1
[open] => 1
[title] => 1. EPLAN Softwarebeschreibung Allgemein
[hns] => eplan_softwarebeschreibung_allgemein:eplan_softwarebeschreibung_allgemein
[file] => //eplan_softwarebeschreibung_allgemein
[return] => 1
[sort] => 0
)
[4] => Array
(
[id] => stammdaten
[type] => d
[level] => 1
[open] => 1
[title] => 2. Stammdaten
[hns] => stammdaten:stammdaten
[file] => //stammdaten
[return] => 1
[sort] => 0
)
[5] => Array
(
[id] => stammdaten:artikelanlage
[type] => f
[level] => 2
[open] =>
[title] => 2.2 Artikelanlage
[hns] =>
[file] => //stammdaten/artikelanlage.txt
[return] => 1
[sort] => artikelanlage
)
[6] => Array
(
[id] => stammdaten:artikelstammdaten
[type] => f
[level] => 2
[open] =>
[title] => 2.1 Artikelstammdaten
[hns] =>
[file] => //stammdaten/artikelstammdaten.txt
[return] => 1
[sort] => artikelstammdaten
)
[7] => Array
(
[id] => stammdaten:makros
[type] => f
[level] => 2
[open] =>
[title] => 2.3 Makros
[hns] =>
[file] => //stammdaten/makros.txt
[return] => 1
[sort] => makros
)
[8] => Array
(
[id] => stammdaten:sprache_und_uebersetzung
[type] => f
[level] => 2
[open] =>
[title] => 2.4 Sprache und Übersetzung
[hns] =>
[file] => //stammdaten/sprache_und_uebersetzung.txt
[return] => 1
[sort] => sprache_und_uebersetzung
)
[9] => Array
(
[id] => stueckliste
[type] => d
[level] => 1
[open] => 1
[title] => 3. Stückliste
[hns] => stueckliste:stueckliste
[file] => //stueckliste
[return] => 1
[sort] => 0
)
[10] => Array
(
[id] => stueckliste:referenzteil
[type] => f
[level] => 2
[open] =>
[title] => 3.1 Artikel in der Stückliste unterdrücken Referenz
[hns] =>
[file] => //stueckliste/referenzteil.txt
[return] => 1
[sort] => referenzteil
)
)
In that case the tsort
looks what you are looking for, it isn’t?
(https://www.dokuwiki.org/plugin:indexmenu#full_syntax)
Unfortunately no. It looks like this:
{{indexmenu>|tsort}}
has no effect.
4. A Test
A1. Administration
1. EPLAN ...
2. Stammdaten
2.3 Artikelanlage
2.1 Artikelstammdaten
I think the HEADLINE-NUMBERING is only executed after sorting. So the sorting must take place after. Look at my last post: ./lib/plugins/indexmenu/syntax/indexmenu.php (407) on this place.
Aha, is this summary more correct: tsort
should be the sorting option that is able to sort your headlines, if the sorter gets titles including the headline numbering. But it probably does not receive this numbering in time, so it not sorting by number.
Quick look in the source code:
If tsort
is set, than $this->sort == 't'
.
Here the search is retrieving the pages:
https://github.com/samuelet/indexmenu/blob/b6553b8b8a03b5bc86dcf7f41289a672381b7917/syntax/indexmenu.php#L400-L406
which uses the callback _search_index() https://github.com/samuelet/indexmenu/blob/b6553b8b8a03b5bc86dcf7f41289a672381b7917/syntax/indexmenu.php#L668
Which retrieves: https://github.com/samuelet/indexmenu/blob/b6553b8b8a03b5bc86dcf7f41289a672381b7917/syntax/indexmenu.php#L759-L763
And set the literal info used by the sorter, by _setorder($item)
:
https://github.com/samuelet/indexmenu/blob/b6553b8b8a03b5bc86dcf7f41289a672381b7917/syntax/indexmenu.php#L954-L958
https://github.com/samuelet/indexmenu/blob/b6553b8b8a03b5bc86dcf7f41289a672381b7917/syntax/indexmenu.php#L965
https://github.com/samuelet/indexmenu/blob/b6553b8b8a03b5bc86dcf7f41289a672381b7917/syntax/indexmenu.php#L777
Your debug from line407, contains strange values for [sort] =>
entries if you request tsort
sorting. Are you sure you test the tsort
option?
Please post you syntax you are using to include this indexmenu in your page.
In my last post I've provided the syntax to render the indexmenu. But here it comes again ;) :
{{indexmenu>|tsort}}
You should also know that the numbering is not in the HEADLINE, but is also represented by a syntax. Only when RENDERING does it become the number, the source code says something like that:
====== -#A.1 Administration ======
====== -#1 EPLAN ... ======
====== -#2 Stammdaten ======
-#1 Starts the numbering at 1 -#2 Starts the numbering at 2
And that is exactly what the HEADLINE says.
ah, sorry, I oversight your syntax example.
Is your debug output above, for that same syntax?
[1] => Array
(
[id] => administration:artikeleinstellungen
[type] => f
[level] => 2
[open] =>
[title] => A1.2 Artikeleinstellungen
[hns] =>
[file] => //administration/artikeleinstellungen.txt
[return] => 1
[sort] => artikeleinstellungen
I observe that from the 'title' entry the -#
part is removed. So this is the parsed title?
If tsort
is enabled, I would expect that [sort] => A1.2 Artikeleinstellungen
and not [sort] => artikeleinstellungen
. So: or I missed a step, or there is a bug I oversight yet, or the tsort
was not set for this example debug output?
Eventuelly you can test with and without ~~NOCACHE~~
. Maybe an old cache is used? Indexmenu plugin try to cache some stuff but maybe the expiring of the caches is not completely fitted to the numbered headline plugin?
Yes, it is ;)
And here the test output:
~~NOCACHE~~
{{indexmenu>|tsort}}
tsort and nocache output:
Array
(
[0] => Array
(
[id] => a_test
[type] => d
[level] => 1
[open] => 1
[title] => 4. A Test
[hns] => a_test:a_test
[file] => //a_test
[return] => 1
[sort] => 0
)
[1] => Array
(
[id] => administration
[type] => d
[level] => 1
[open] => 1
[title] => A1. Administration
[hns] => administration:administration
[file] => //administration
[return] => 1
[sort] => 0
)
[2] => Array
(
[id] => administration:epis
[type] => f
[level] => 2
[open] =>
[title] => A1.1 EPIS Menüleiste
[hns] =>
[file] => //administration/epis.txt
[return] => 1
[sort] => A1.1 EPIS Menüleiste
)
[3] => Array
(
[id] => administration:artikeleinstellungen
[type] => f
[level] => 2
[open] =>
[title] => A1.2 Artikeleinstellungen
[hns] =>
[file] => //administration/artikeleinstellungen.txt
[return] => 1
[sort] => A1.2 Artikeleinstellungen
)
[4] => Array
(
[id] => eplan_softwarebeschreibung_allgemein
[type] => d
[level] => 1
[open] => 1
[title] => 1. EPLAN Softwarebeschreibung Allgemein
[hns] => eplan_softwarebeschreibung_allgemein:eplan_softwarebeschreibung_allgemein
[file] => //eplan_softwarebeschreibung_allgemein
[return] => 1
[sort] => 0
)
[5] => Array
(
[id] => stammdaten
[type] => d
[level] => 1
[open] => 1
[title] => 1.
[hns] => stammdaten:stammdaten
[file] => //stammdaten
[return] => 1
[sort] => 0
)
[6] => Array
(
[id] => stammdaten:artikelstammdaten
[type] => f
[level] => 2
[open] =>
[title] => 2.1 Artikelstammdaten
[hns] =>
[file] => //stammdaten/artikelstammdaten.txt
[return] => 1
[sort] => 2.1 Artikelstammdaten
)
[7] => Array
(
[id] => stammdaten:artikelstammdaten_bearbeiten
[type] => f
[level] => 2
[open] =>
[title] => 2.2 Artikelstammdaten bearbeiten
[hns] =>
[file] => //stammdaten/artikelstammdaten_bearbeiten.txt
[return] => 1
[sort] => 2.2 Artikelstammdaten bearbeiten
)
[8] => Array
(
[id] => stammdaten:artikelanlage
[type] => f
[level] => 2
[open] =>
[title] => 2.3 Artikelanlage
[hns] =>
[file] => //stammdaten/artikelanlage.txt
[return] => 1
[sort] => 2.3 Artikelanlage
)
[9] => Array
(
[id] => stammdaten:makros
[type] => f
[level] => 2
[open] =>
[title] => 2.4 Makros
[hns] =>
[file] => //stammdaten/makros.txt
[return] => 1
[sort] => 2.4 Makros
)
[10] => Array
(
[id] => stammdaten:sprache_und_uebersetzung
[type] => f
[level] => 2
[open] =>
[title] => 2.5 Sprache und Übersetzung
[hns] =>
[file] => //stammdaten/sprache_und_uebersetzung.txt
[return] => 1
[sort] => 2.5 Sprache und Übersetzung
)
[11] => Array
(
[id] => stueckliste
[type] => d
[level] => 1
[open] => 1
[title] => 3. Stückliste
[hns] => stueckliste:stueckliste
[file] => //stueckliste
[return] => 1
[sort] => 0
)
[12] => Array
(
[id] => stueckliste:referenzteil
[type] => f
[level] => 2
[open] =>
[title] => 3.1 Artikel in der Stückliste unterdrücken Referenz
[hns] =>
[file] => //stueckliste/referenzteil.txt
[return] => 1
[sort] => 3.1 Artikel in der Stückliste unterdrücken Referenz
)
)
End first test with nocache and tsort
{{indexmenu>|tsort}}
only tsort output
Array
(
[0] => Array
(
[id] => a_test
[type] => d
[level] => 1
[open] => 1
[title] => 4. A Test
[hns] => a_test:a_test
[file] => //a_test
[return] => 1
[sort] => 0
)
[1] => Array
(
[id] => administration
[type] => d
[level] => 1
[open] => 1
[title] => A1. Administration
[hns] => administration:administration
[file] => //administration
[return] => 1
[sort] => 0
)
[2] => Array
(
[id] => administration:epis
[type] => f
[level] => 2
[open] =>
[title] => A1.1 EPIS Menüleiste
[hns] =>
[file] => //administration/epis.txt
[return] => 1
[sort] => A1.1 EPIS Menüleiste
)
[3] => Array
(
[id] => administration:artikeleinstellungen
[type] => f
[level] => 2
[open] =>
[title] => A1.2 Artikeleinstellungen
[hns] =>
[file] => //administration/artikeleinstellungen.txt
[return] => 1
[sort] => A1.2 Artikeleinstellungen
)
[4] => Array
(
[id] => eplan_softwarebeschreibung_allgemein
[type] => d
[level] => 1
[open] => 1
[title] => 1. EPLAN Softwarebeschreibung Allgemein
[hns] => eplan_softwarebeschreibung_allgemein:eplan_softwarebeschreibung_allgemein
[file] => //eplan_softwarebeschreibung_allgemein
[return] => 1
[sort] => 0
)
[5] => Array
(
[id] => stammdaten
[type] => d
[level] => 1
[open] => 1
[title] => 1.
[hns] => stammdaten:stammdaten
[file] => //stammdaten
[return] => 1
[sort] => 0
)
[6] => Array
(
[id] => stammdaten:artikelstammdaten
[type] => f
[level] => 2
[open] =>
[title] => 2.1 Artikelstammdaten
[hns] =>
[file] => //stammdaten/artikelstammdaten.txt
[return] => 1
[sort] => 2.1 Artikelstammdaten
)
[7] => Array
(
[id] => stammdaten:artikelstammdaten_bearbeiten
[type] => f
[level] => 2
[open] =>
[title] => 2.2 Artikelstammdaten bearbeiten
[hns] =>
[file] => //stammdaten/artikelstammdaten_bearbeiten.txt
[return] => 1
[sort] => 2.2 Artikelstammdaten bearbeiten
)
[8] => Array
(
[id] => stammdaten:artikelanlage
[type] => f
[level] => 2
[open] =>
[title] => 2.3 Artikelanlage
[hns] =>
[file] => //stammdaten/artikelanlage.txt
[return] => 1
[sort] => 2.3 Artikelanlage
)
[9] => Array
(
[id] => stammdaten:makros
[type] => f
[level] => 2
[open] =>
[title] => 2.4 Makros
[hns] =>
[file] => //stammdaten/makros.txt
[return] => 1
[sort] => 2.4 Makros
)
[10] => Array
(
[id] => stammdaten:sprache_und_uebersetzung
[type] => f
[level] => 2
[open] =>
[title] => 2.5 Sprache und Übersetzung
[hns] =>
[file] => //stammdaten/sprache_und_uebersetzung.txt
[return] => 1
[sort] => 2.5 Sprache und Übersetzung
)
[11] => Array
(
[id] => stueckliste
[type] => d
[level] => 1
[open] => 1
[title] => 3. Stückliste
[hns] => stueckliste:stueckliste
[file] => //stueckliste
[return] => 1
[sort] => 0
)
[12] => Array
(
[id] => stueckliste:referenzteil
[type] => f
[level] => 2
[open] =>
[title] => 3.1 Artikel in der Stückliste unterdrücken Referenz
[hns] =>
[file] => //stueckliste/referenzteil.txt
[return] => 1
[sort] => 3.1 Artikel in der Stückliste unterdrücken Referenz
)
)
I see: only the first level isn't sorted. Can you confirm this.
I think namespace sorting is missing. Could you add the nsort
option as well? tsort
is default only applied for pages, and not yet for namespaces.
Thank you so much.
{{{indexmenu>|nsort tsort}}
is the solution, without any programming :)
Ok, nice! Thanks for the debug info. Enjoy it!
How can I change the sorting algorithms to first by numbers and second by letters. My headlines (and my sorted list) are
The menu is rendered as follows
A1. Appendix A2. Some other appendix
regards raiserle