Admin plugin changes page type

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.

Where should I begin to look?

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.

First; thanks a lot for the fast response!

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…

Unless your Twig (rendered HTML) file differs from language to language, you just need to a separate markdown (content) file.

E.g. have a single product.html.twig, have various content languages: product.en.md, product.fr.md

Unfortunately they do differ some. But if there’s no other way I might have to find a work around.

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.”

Line 6 in the Twig-file looks like this:

<h4>{{ product.header.taxonomy.type }}</h4>

The original working header looks like this:

title: foo
menu: foo
slug: foo

taxonomy:
  category: something
  tag: something
  type: something
content:
  items: '@self.modular'
  order: 
    by: default
    dir: asc
    custom:
      - _foo
      - _bar
short_facts:
  - fact_name: foo
    fact: bar
  - fact_name: foo
    fact: bar
  - fact_name: foo
    fact: bar
  - fact_name: foo
    fact: bar

and after saving the page in the Admin panel it looks like this:

title: something
menu: something
slug: something
taxonomy:
    type:
        - 'something'
    tag:
        - something
    category:
        - 'Something'
content:
    items: '@self.modular'
    order:
        by: default
        dir: asc
        custom:
            - _foo
            - _bar
short_facts:
    -
        fact_name: 'Foo'
        fact: 'Bar'
    -
        fact_name: 'Foo'
        fact: 'Bar'
    -
        fact_name: 'Foo'
        fact: 'Bar'
    -
        fact_name: 'Foo'
        fact: 'Bar'

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?

…and yes, I have tried to remove or add the citation marks but it makes no difference as long as I use the first way of writing the header.

Taxonomies are defined as lists, so they are stored as arrays.

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.)