AugustMiller / kirby-place-field

Deprecated! A simple Google Maps field for Kirby CMS. Please use my Map Field plugin, instead:
https://github.com/AugustMiller/kirby-map-field
21 stars 3 forks source link

Store location data in markdown instead of JSON #8

Closed JimmyRittenborg closed 8 years ago

JimmyRittenborg commented 9 years ago

Why is the location data stored in JSON over markdown in the markdown files?

Can't we keep the data clean and readable in the markdown format - some people edits the content through dropbox.

AugustMiller commented 9 years ago

I'm not sure exactly how you anticipate the structured data being stored in Markdown, but I've planned to move over to YAML for a while, now. This would allow a better, human-readable storage scheme, more in line with Kirby's Structure field.

Unfortunately, there seems to be reasonably wide adoption (despite notices in the Readme!), so a sudden change in master might well upset some developers and administrators. I'd like to run YAML storage in an alternate branch aimed at a 1.0 release… We'll see.

JimmyRittenborg commented 9 years ago

So instead of a cold-turkey - could it be softly solved in some way along the lines like this?

Check for a if the current value already is JSON

public function isJson($string) {
  json_decode($string);
  return (json_last_error() == JSON_ERROR_NONE);
}

if it's true use JSON else just use YAML - the change will be better now than later, i think :see_no_evil:

JimmyRittenborg commented 9 years ago

Currently we can't use straight out

if( $page->location()->isNotEmpty() ):

in templates to check if the a map should be showed, because the field will after a save, always contain JSON regardless if it's filled or not :grin:

AugustMiller commented 8 years ago

Should have updated this thread when I started working on the switch, but as of cde31391aa148d410a9b47315103c5116d7a03d2, data is stored in YAML!