Can I use custom fields somehow in the admin panel?

Let’s say I need a header image for a blog post. Apparently the way to do it now is to upload an image to Page Media and then copy/paste the name to the YAML file or to use the Expert setting on the Admin panel and write it there. That seems unnecessarily difficult. Is there a way to create a custom field where I could upload the image and it would automatically add the image name to the YAML file?

One other thing too - any other ways to use global variables other than to write everything on site.yaml? I have things like emails and addresses which are the same site-wide and I’d need to figure out a client-friendly way to access them.

Hi @dimis,

you have two questions. Concerning the first one, I don’t know any other way. Maybe the Grav Team can tell you more about it. But in any case you are able to use your own admin theme (see here) with template inheritance, adding a custom form field in your theme/templates/forms/fields + (modifying some other template files) and add your logic either into the themes php file or into a plugin.

Concerning your second question you may store you settings in a separate YAML file located in the user/config folder, i.e. accounts.yaml with

—yaml
username:
email: blah@blah.domain
address: somewhere and nowhere


Then you can access them in Twig via `{{ config.accounts }}`. Or you write an (admin) plugin like https://github.com/getgrav/grav-plugin-data-manager to manage your data. It depends on your use case and it is hard to tell what you want to have. Do you want to provide us with more informations?

Thanks sommerregen!

To clarify the second question a bit, what I’m looking for is something like Republic Variables on ExpressionEngine (image here). For example, in the image there’s a variable called address (in red on the left side) and on the right side of it are the English, German and Swedish versions of the address variable. In EE you simply need to call {address-de} in the template and it will then display the correct version of the address in the rendered template (in this case, German).

So basically what you suggested. I could add everything to the user/config folder and call them from there like you said, but I was wondering if there’s a plugin or something in the works that would automate it and make it a little bit easier for clients. If I need to tell a client that they need to log into the FTP server and modify files manually, I can imagine the confused stares I’d get :slight_smile:

Both of these things you mention are features we had planned to provide as part of the “Pro Plugin”.

The first part of your questions relates to image metadata handling, and we plan on bringing a manager of sorts to the pro version of the admin to allow this.

The second part seems to be two fold. One a configurable set of site-wide options that you can give access to that resides outside of the config and site yaml files. While this is possible with Grav now, by adding a custom yaml file in user/config/, there is no admin interface for it. Again this is something that was set aside for the pro admin.

The other part relates to language specfiic translation strings. This again, is something we hope to bring to the pro admin in the form of a language editor.

Thanks for the reply! I know asking for ETAs is bad manners… but is there an ETA? :slight_smile:

No ETA, but we are starting on the Pro plugin very very soon.