We are running a Grav site with over 1000 pages, and we noticed that the pages field in the Admin panel does not display all pages. Here’s the current blueprint configuration we are using:
YAML
.link:type:pagessize:largeclasses:fancyshow_all:trueshow_root:trueshow_modular:truetoggleable:truelabel:Internal Link (Page or Section)
Even with show_all: true, we don’t see all pages in the dropdown. We suspect there might be a limit on how many pages are displayed due to performance constraints or a hardcoded limit in Grav’s Admin plugin.
Questions:
Is there a known limit to how many pages the pages field can display in the Admin panel?
Are there any workarounds or alternative solutions for handling a large number of pages?
Would switching to a different field type (e.g., selectize) or implementing an AJAX-based lazy-loading solution be a viable option?
Since our page count will continue to grow, what are the best practices for handling performance when dealing with thousands of pages in the Admin panel?
We use git-sync Plugin and the performance is really slow.
Any insights, workarounds, or suggestions would be greatly appreciated!
The problem is that it stops scrolling at this point even though there are more pages. However, there are no other listed in the HTML source code of the dropdown.
In file system/src/Grav/Common/Page/Pages.php, function getList, I had the pages printed out the result with var_dump($list); and many more are printed out than are available in the dropdown box.
@christiana83, Bit late to the party, but did some research anyway...
TL;DR:
I can reproduce the issue
1000 seems to be a hardcoded limit
Steps to reproduce:
Using default Grav+Admin installation
Create shell script to create 2000 pages:
BASH
for f in{3..2000}domkdir"user/pages/$f.page$f"echo"Page $f">"user/pages/$f.page$f/default.md"done
Added the page field to user/themes/quark/blueprints/default.yaml:
YAML
.link:type:pagessize:largeclasses:fancyshow_all:trueshow_root:trueshow_modular:truetoggleable:truelabel:Internal Link (Page or Section)
Opened Admin and page Typography
When selecting the page field, it shows 1000 pages (root page + 999 pages):
Research:
Searched in Developer Console of Chrome for some unique element properties for the Page field: "selectize-dropdown-content"
Searched in ./user/plugins/admin/themes/grav/ for "selectize-dropdown-content"
Found it in user/plugins/admin/themes/grav/js/vendor.min.js
With some more searching, found function refreshOptions line 76261, which contains the following snippet just before creating all options (line 76275):
TXT
// build markup
n = results.items.length;
if (typeof self.settings.maxOptions === 'number') {
n = Math.min(n, self.settings.maxOptions);
}
settings.maxOptions is set to 1000 on line 77415
TXT
maxOptions: 1000,
Unfortunately, I've found no option in Admin or the definition of field Page to alter the value for maxOptions. But, I might be missing something...
When I add this field to user/themes/quark/blueprints/default.yaml:
YAML
header.link:type:parentslabel:Internal Link (Page or Section)classes:fancy
The field will look like:
And when clicking the field, a modal form will display all 2000 pages:
Not knowing your use-case and (UX) requirements, but it seems the undocumented "parents" field might (at least partially) solve the issue of showing 1000+ pages.
Uh, no, I haven't been able to change the title "Parents" (yet).
I replaced the pages field with the (undocumented) parents field type, and now all pages are listed—no more 1,000-item cap—and the selector is much more user-friendly:
YAML
header.link:type:parentslabel:Internal Link (Page or Section)classes:fancy
This gives you the same modal picker used by the “New Page” form, but without any hard limits and with a smoother UX. Highly recommended!