Dynamic List/Menu Extension Draft #148
taufik-nurrohman
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
This is a dynamic list/menu extension documentation initiation.
File/Folder
Extension name will be
list. This extension will create.\lot\listfolder automatically to store list data as a YAML file. Those files then can be used by the layout developer to generate configurable navigation bar or link list to be placed in sidebar and footer:.\ └── lot\ └── list\ ├── blog-roll.yaml ├── links.yaml ├── nav.yaml └── …Data
A list file contains data like this:
Without a
linkattribute, list item will be rendered as plain text.A non-array value in a list item will be treated as the
titlevalue:List items order will be arranged as-is. A sortable graphical user interface can be developed to help managing those items.
List can also be sourced from a page. That way, items can be generated automatically:
The value of
fromattribute is a private file path relative to thePATHconstant value. When parsed, the source value will be resolved into a valid file path and then every data parsed from that path will be populated to the list item automatically as the default value.Other data stored directly in the list item will override the generated list data. For example, the
titleanddescriptionvalue below will override thetitleanddescriptionvalue from the page file:If
fromfile has page children, those page files will be parsed as well and then the generated data will be populated to thelistattribute. This is very useful for making automatic multi-level navigation. To limit the number of sub-menu generated, users can add achunkattribute. And to limit the depth of automatic sub-menu generation, users can adddeepattribute, just like in the built-in site page-ing system:List item visibility can be set through the source file itself. Lets say, we have a page children of
.\lot\page\courses.pagestored as.\lot\page\courses\chemistry.page. By default, this page will be included as a sub-menu for “Courses”. But users can exclude it by addingskipattribute withtruevalue to the “Chemistry” page:If
skipattribute is not set, the value will be determined by the current file extension. If its extension is.page, it will be treated as a valuefalse, if its extension is.archive, it will be treated as a valuetrue. Extension.draftwill always be ignored.Layout
A base
listlayout can be added. The HTML markup generation is up to the layout developer, but I encourage you to only generate a heading element (to render thetitlevalue), a paragraph (to render thedescriptionvalue) and a list (to render thelistdata either as ordered list or as unordered list). This extension should only provide the data.Calling the default list layout can be done like this. Data are provided via array:
If the first argument is a string, then it will be treated as a list source ID, which is the list file name:
Use the second argument to override the list data:
The problem is that
listis a reserved keyword. I have not been tested it. But in PHP 8, it should be possible to use reserved keywords as PHP methods:Panel
A sortable user interface is needed to render the list data in Panel. A dialog window feature may be needed as an editor for the list item.
For better user experience in selecting file path to fill the
fromattribute, an AJAX powered fuzzy finder interface 1 2 may be needed. So yeah, this is a complex feature.Footnotes
https://github.com/loilo/Fuse ↩
https://github.com/krisk/fuse ↩
Beta Was this translation helpful? Give feedback.
All reactions