getgrav / getgrav/grav-plugin-admin

If you set a page to 'External' template and save, you cannot change it to a different template without first setting URL

Open
#2,137 1 comment 0 reactions 1 assignee Claimed by @mahagr View on GitHub
bug
Dominant language
PHP
Stars
377
Forks
225
Avg merge
11h 51m
Merged PRs (30d)
4

Description

Ran into this issue when I built a test page to tinker around and see how the different templates affected things.

Test case:

1. Create simple page and leave default template at 'Default' and save.
2. Visit URL of test page. It should look as expected.
3. Go to 'Advanced' tab, and change Page Template: to 'External' and save.
4. Reload test page. Should get a blank page. (Initially didn't realize you set the Extenral URL back under the 'Content' tab. But note that page saves here even WITHOUT a URL set.)
5. Change Page Template: back to 'Default'. When you try to save, [Save] button doesn't work. Rinse/repeat trying to change templates, switching to/from this page, etc.

Now this MAY be by design, but it seems off.

In the end, in order to change away FROM the 'External' template, I first had to set the External URL: under the 'Content' tab, at which point [Save] worked again. This let me save the page with the 'External' template. And only THEN could I change the template back to 'Default' and save.

Also, I noticed in redoing this test case (which is very reproducible) that when I switched the page BACK to 'External', the URL I'd set in order to save the page was still there. Of course, once a page template is set to 'Default', that URL field is no longer shown under 'Content', so there's no easy way to remove this in the UI, shy of selecting [Expert] mode in the editor and manually gutting it. This may be by design, so folks can switch a page from internal content to external quickly, but wanted to note this all the same.

But it might be useful for whatever front-end code is preventing the page save to check if the template IS, in fact, still set to 'External' before requiring that a URL be set in order for [Save] to work. A user setting a page template to 'Default'/etc. should negate that requirement. I get why it may not be able to require a URL when you first change a template TO 'External', as at that point the External URL: field doesn't exist under 'Content'. But I would think the logic should check a template setting before saving to confirm it hasn't been changed.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.