How to add Custom Fields to all subpages

Hi there,

I have a careers page on a Grav site I’m building. This is the first project using Grav.

What I have done so far is to add Modular subpages for each of the jobs available. (not sure if this is the correct thing to do or not…

So these appear correctly like:

/careers/job-one
/careers/job-two

What I need to do now is add a custom field to these pages (this is where I am stuck)… I’ve tried adding the blueprint in the module folder but these don’t show up.

What I need to add is a category for each of these jobs, so that a results page can be made, for example, a page showing all the jobs where category = ‘1’ for example… Another page where category = ‘2’

I’m used to WordPress, so this basically needs to work as a Custom Post Type…

If anybody can help with this, that would be much appreciated.

@mrnaysilva, have you considered using a kind of blog structure? Or parts of the blog structure?

  • Blog items (item.md) typically contain a field ‘taxonomy’ with categories/tags. These could be your individual job pages.
  • The main blog page (blog.md) shows its own content together with a list of blog items. The list of blog items can be a selection of all items based on the ‘taxonomy’ field.
  • There are plugins supporting the blog structure like pagination, list of categories, date related archives, etc.

Of course you will probably need to copy/adapt the ‘blog’ and ‘item’ templates to suit your needs.

Thanks for your response.

So how can I go about copying the /blog/ structure

I’ve used the fields from the blog.md and I’ve added this to 06.careers (careers.md) file.

But this doesn’t seem to make it work like the Blog. Am I missing something?

Do the pages need to be added as standard pages, or modular pages?

In addition, how is it possible to add blueprints (custom fields) to child pages of the /careers/ page?

I’m pretty lost here to honest so any help would be massively appreciated!

@mrnaysilva, forgot to mention that the ‘Site Blog’ skeleton might a good site to start playing with. You can download it here.

When using a blog like structure, you don’t don’t use modular pages.

To learn about adding extra fields to the blueprint of a page, you can start with reading about blueprints in general and Example: Page Blueprints in the docs.

Great thank you, I understand the Blueprints for pages / page templates.

I’m just unsure how you define custom fields to only the child pages.

I.e. I want to add a custom field to /careers/some-job-here and not add them to /careers/ as I already have custom fields added to this.

@mrnaysilva,

You wrote:

I’m just unsure how you define custom fields to only the child pages.

You can do this by adding the custom fields to the blueprint defined for the child pages. In Quark’s folder ‘/user/themes/quark/blueprints/’, you can see it has blueprints for the different page types: ‘blog’, ‘default’, ‘item’, etc.