This is probably (I hope) a real newbie error. But at the moment its’ driving me crazy.
I’ve set up a Grav site with the admin plugin installed, created my own template and begun to fill it with content. Up till now I’ve been using a text editor. Everything looks and works great until…
When I make changes to a page using the Admin interface and save it, the page type changes from my custom template (product.html.twig) to blog.html.twig, which I don’t use at all anywhere.
In the header of the page file I’ve pointed to the custom template like this
template: product
…but it still changes to blog.
I think we have an issue for this already. Grav Admin is currently merging the page-level templates in your theme, any blueprints assigned for those, with the system list.
I think the issue is related to you setting the template type as a header, rather than actually naming your markdown file product.md . If you rename the file and don’t use the template override it should work.
This is just a workaround, but the bug needs to be fixed.
The markdown file is actually named product.md, I just set the template in the header too as a safety. However, after reading your answer I’ve removed the template from the header and the result is still the same :´(
When I look under the Advanced tab in the Admin panel, the option Page File is set to Blog. Even if I change it to the correct template it still saves it as blog.
(I don’t know if it matters, but they’re really named product.sv.md and product.sv.html.twig since I’m also using the Langswitcher plugin.)
I think your issue actually is related to the language-specific Twig file, which could not be supported by the Admin plugin. Using product.html.twig should work. Will check this too.
Thanks! Unfortunately for me, I really need to use the Langswitcher plugin. Is there an other way to use it without having to use language specific templates? I followed what was written in the Grav documentation…
Will get it to work in the next release, but currently you can do language check in that single Twig file, OR do not save pages through Admin, only edit them using a text editor.
I’ve solved the initial problem by doing a language check in the Twig template. So far so good.
But I still suffer som problems from the Admin panel. When I save a page it changes the header in a way that makes it not work anymore.
The error I get looks like this:
Twig_Error_Runtime thrown with message “An exception has been thrown during the rendering of a template (“Array to string conversion”) in “partials/product-preview.html.twig” at line 6.”
The error I get suggest that it has something to do with the taxonomy type property. But the only difference I can see are the citation marks and the spacing. What am I missing?
Admin auto-corrects your manual page header which it thinks it’s wrong. If you want to store it differently, add your own field type using a custom page blueprint.
OK, as I assumed I did something wrong. But why does it work when I do it wrong and not when admin auto corrects? Shouldn’t it be the other way around and what is it that makes it malfunction? (As you probably understand I’m a designer and not a programmer at heart.)