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
-
This is a dynamic list/menu extension documentation initiation.
File/Folder
Extension name will be
list
. This extension will create.\lot\list
folder 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:Data
A list file contains data like this:
Without a
link
attribute, list item will be rendered as plain text.A non-array value in a list item will be treated as the
title
value: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
from
attribute is a private file path relative to thePATH
constant 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
title
anddescription
value below will override thetitle
anddescription
value from the page file:If
from
file has page children, those page files will be parsed as well and then the generated data will be populated to thelist
attribute. This is very useful for making automatic multi-level navigation. To limit the number of sub-menu generated, users can add achunk
attribute. And to limit the depth of automatic sub-menu generation, users can adddeep
attribute, 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.page
stored 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 addingskip
attribute withtrue
value to the “Chemistry” page:If
skip
attribute 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.draft
will always be ignored.Layout
A base
list
layout 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 thetitle
value), a paragraph (to render thedescription
value) and a list (to render thelist
data 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
list
is 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
from
attribute, 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