Dynamic Frontmatter Values (Geocoding)

I’m trying to create a plugin that will geocode address information input via an admin blueprint and dynamically return / assign latitude and longitude values to the page header. I have made the plugin work using the onPageContentRaw event hook, but this only saves to the cache rather than to the markdown file itself. Do I need to create a public function in the plugin and then use a function call (data-*@) in the page blueprint to make this value permanent? This is the first plugin I’ve written, and would appreciate some help. Right now my form looks like this:

Title
Address 1
City
State

and I would like it to take the values put into those last three and process the lat and long so that my page header looks like this:

title: XXXXX
address1: XXXXX
city: XXXXXX
state: XX
latitude: XXX
longitude: XXX

Thanks in advance for the help!

See existing iplocate plugin.

The geolococating isn’t a problem, I have that working. My issue is either choice of event hooks or integrating a function in my blueprints to get the value assigned to the header of the page markdown file.

If you look at that plugin, you will see that it makes its data available via the config.plugins.iplocate namespace, which is just one way of accomplishing this. I will suggest a section to the Learning by Example section on this.

OK, this makes some sense, thanks for the help. Now how would I reference that value in a page blueprint to store in the markdown file?

I don’t use the Admin plugin (which I think is what you’re referring to by “page blueprint”). In normal Twig, I just insert the data directly: {{ config.plugins.iplocate.whatever.variable}}.

There are a couple of different ways to accomplish this. I just submitted the following pull request with the basic instructions:

That’s correct, I’m building a site for a real estate client that wants their properties loaded into a searchable google map. I’m treating the properties similarly to blog posts, where they input the information via the admin plugin to create each page folder and markdown file. So I’m not using twig, instead I’m trying to dynamically write frontmatter so that the person inputting the data doesn’t need to geocode each property and then put that value manually into the field. I’ve tried using different event hooks, but I can’t solve how to actually write the response to the markdown file.

Well, that pull request shows at least three different ways of doing this. You are still using Twig. That’s how the templates work. Look at the Import plugin, which inserts data into the page header and shows you how to access it in Markdown.