Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Forms & Blueprints

Advanced blue print for multi level front matter

Started by Dean Bateman 8 years ago · 5 replies · 677 views
8 years ago

I am trying to create a blueprint for the front matter data below, can someone suggest to me how I can set my data out in this structure

I have previously created fields with list but this data structure is a whole load more complex so any suggestions would be greatly appreciated

YAML
type: "FeatureCollection"
features:

  - geometry:
      type: "Point"
      coordinates:
        - 104.67
        - -26.62
    type: "Feature"
    properties:
      category: "category"
      hours: "9am - 5pm"
      description: "<p>Description</p>"
      company: "Company Name"
      name: "Contact Name"
      address: "Address"
      phone: "phone1"
      phone2: "phone2"
      email: "email1"
      email2: "email2"
      website: "website1"
      facebook: "website2"

  - geometry:
      type: "Point"
      coordinates:
        - 104.67
        - -26.62
    type: "Feature"
    properties:
      category: "category"
      hours: "9am - 5pm"
      description: "<p>Description</p>"
      company: "Company Name"
      name: "Contact Name"
      address: "Address"
      phone: "phone1"
      phone2: "phone2"
      email: "email1"
      email2: "email2"
      website: "website1"
      facebook: "website2"
8 years ago

Hello dean_007.

GRAV Frontmatter is agnostic as long as the yaml syntax is correct. This means you can use the Frontmatter to store data structures "unknown" to GRAV. The GEO data structure you expose here cannot be handled by GRAV out of the box and I don't know if there's a plugin that allows you to handle this. What's probably needed is a dedicated plugin and / or field type for this data or you have to rewrite the data structure to adapt to what's available out of the box in GRAV. GRAV offers exhaustive information on fields, types, collections and their usage in pages: Learn GRAV: Forms

8 years ago

the way I have approached this is to use a list at the features level

YAML
header.features:
      name: Features
      type: list
      style: vertical
      label: Features

then create a custom heading underneath

YAML
.geometry.type:
   type: select
   label: Select one of the following geometry types
   default: Point
.type:
     type: hidden
     default: "Feature"
.properties.hours:
      type: text
      label: Enter Opening Hours

I'm still to work out how to create the coords yet, but with a little persistence I'm sure ill get there

TXT
coordinates:
        - 55.588
        - -32.627
8 years ago

For the coordinates you could use the Array Field with 'value_only: true'

👍 1
8 years ago

I did try the Array field originally but overlooked the value only, it works but I need the value to be saved as a number and not a string i.e. 174.7676 instead of '174.7676'

to resolve the other issues is used this to save my data I used a field sets for geometry and properties worked like a charm using lists just didn't work with other sublevel items

8 years ago

There is also the multilevel field, which is still a WIP and not documented yet, but could fit your needs.

Suggested topics

Topic Participants Replies Views Activity
Forms & Blueprints · by Ton Haarmans, 5 years ago
13 1133 4 months ago
Forms & Blueprints · by Hugo Oliveira, 5 months ago
0 60 5 months ago
Forms & Blueprints · by Flachy Joe, 6 months ago
9 131 6 months ago
Forms & Blueprints · by Augustus, 7 months ago
7 107 7 months ago
Forms & Blueprints · by Julien, 7 months ago
10 125 7 months ago