Access field-values of .md files in the config file?


I’ve set the content file extension to .md.

Now, in the config file I’m also trying to get
the value of a page field, but the output is empty.

c::set('my.setting', page('mypage')->awesome_field());

Do I have to use .txt files in order to have access to
field values of a specific page, or am I just missing something?

Is that a single language site or multi-language?

It’s a single language site.

Edit: Maybe I should mention, that I changed the already existing file extensions of all txt-files to .md in the content folder.

Indeed there seems to be a difference in behaviour between .txt and .md files, but accessing site or page from the config file settings doesn’t sound like such a great idea. Why do you need this field’s content as a config setting anyway, given that you can access that field from anywhere?

I have set up an e-mail field for the client, which he can update on the contact page.
In want to have access to this e-mail field in the config settings from a plugin.
I also want to reuse that plugin in other projects, without having to touch its source-code again.
But in other projects the e-mail source might be on a different page or even directly put into the settings.

I guess You’re right, it’s probably not the best idea to access page fields in the config file - and as I’m writing this reply, I realize that I’m making things unnecessarily too complicated.
Maybe should quit for today and re-think about my code-structure tomorrow…
Thank You Sonja!