Hi! Grav newbie here with a question: is there a way in the admin to change the folder number prefix?
I am using this to order collections and would like to access this from admin. Is this not possible or is there other way to achieve a custom / manual order from admin?
I think this description is wrong. Maybe something like:
The Ordering section gives you the ability to use drag and drop to reorder pages that are siblings to the current page (this will modify each page’s folder’s number prefix).
Disabling the number prefix hides the page in the navigation (makes it invisible) and disables it in the Sortable Pages interface."
Well… I have a mix of numbered and not numbered folders and they all are visible unless I specifically set visibility to false I’ll have to check this again to be 100% sure, but IIRC, that’s how it’s on my website
You are right, the page without folder prefix is included in pages.children.
New version:
The Ordering section gives you the ability to use drag and drop to reorder pages that are siblings to the current page (this will modify each page’s folder’s number prefix).
Disabling the number prefix is equivalent to setting the page ‘visible’ variable to false and disables it in the Sortable Pages interface.
What does what with respect to a page’s ‘visibility’ property and hidden/visible menu-items?
Admin:
‘Folder Numeric Prefix’
Enabling field ‘Folder Numeric Prefix’ only adds a numeric prefix to the folder containing the page file. Disabling removes the numeric prefix.
It does not ‘set’ the visibility or anything else of a page.
‘Sortable pages’
This array field, allows the user to order siblings having a numeric prefix. It changes the order, by changing the numeric prefixes of the folders.
It does not ‘set’ anything else.
Grav core:
It is the core that sets the page’s visibility property depending the page’s frontmatter and attributes of its folder.
When a page gets initialized it runs (amongst others) the following methods that impact property ‘Page::visible’. In order of execution:
Page::header();
Sets ‘Page::visible’ according the value set in frontmatter
Page::visible();
If ‘Page::visible’ has not yet been set, set it according the presence of numeric prefix of folder.
Page::modularTwig(strpos($this->slug(), ‘_’) === 0);
Sets ‘Page::visible’ to false if is a modular page.
Page::published();
If Page::published is false, set Page::visible to false
Collections:
A collection adds pages according the ‘items’ field in the definition. It does not discriminate between visible/invisible. Both are added.
It provides functions ‘Collection::visible()’ and ‘Collection::invisible()’ to filter based on the value of ‘Page::visible’
Menu:
A menu is only defined in a template. A template can create a menu as it sees fit. Usually, a collection of pages is being used to create the menu. In particular the collection of children of a page: ‘page.children’. And more specifically only the visible children: ‘page.children.visible’.
Summary:
Showing/hiding menu-items based on property ‘Page::visible’ is a convention.
Only the templates, by adhering to the convention, shows/hides menu-items. Not Admin, nor core.
Enabling/disabling ‘Folder Numeric Prefix’ in Admin, may have the side effect that a page is shown or not shown in the menu.
NB: Please correct me if my view on this should be corrected…
If, during initialisation of the page, ‘Page::visible’ has already been set by frontmatter, the value will not be overridden by the later check for the presence/absence of a numeric prefix of the folder.
But how are numbered folders different from non-numbered? They are exactly the same, except, that it lets you order them more easily. IMO numeric prefix should have nothing to do with visibility.
The other thing that the numeric portion of the folder name does is explicitly inform Grav this page should be visible in the menu. It is important to note that the numeric portion up to and including the . will be removed from URLs.
There is no difference indeed, but it does have a side effect by convention/rule/definition.
Must have forgotten this part when I read the docs a few months ago Good that it’s documented, but still a weird decision to change visibility depending on property that’s supposed to be for ordering