Skip to content

Instantly share code, notes, and snippets.

@jackmcdade
Created July 3, 2019 16:33
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jackmcdade/27392f9907499b9ce1c0cf00d6c76fe9 to your computer and use it in GitHub Desktop.
Save jackmcdade/27392f9907499b9ce1c0cf00d6c76fe9 to your computer and use it in GitHub Desktop.
Statamic Fieldset for Head and Footer Scripts
title: 'Site Settings'
hide: true
sections:
main:
fields:
head_scripts:
mode: table
fields:
description:
type: text
display: Description
code:
type: textarea
display: Code
type: grid
instructions: 'Add meta tags and scripts to the `<head>` area of your site.'
display: 'Head Scripts'
add_row: Add Code
footer_scripts:
mode: table
fields:
description:
type: text
display: Description
code:
type: textarea
display: Code
type: grid
instructions: 'Add meta tags and scripts right before closing `</body>` area of your site.'
display: 'Footer Scripts'
add_row: Add Code
@austriker27
Copy link

Hey @jackmcdade, I reference this all the time. So thank you! That being said I'd love if it was updated for Statamic V3. (I tried my hand at recreating it for S3 but wasn't successful yet)

@jackmcdade
Copy link
Author

jackmcdade commented Oct 16, 2020

Here it is as a v3 Fieldset.

title: Globals
fields:
  -
    handle: head_scripts
    field:
      fields:
        -
          handle: description
          field:
            input_type: text
            display: Description
            type: text
            listable: hidden
        -
          handle: code
          field:
            theme: material
            mode: htmlmixed
            indent_type: tabs
            indent_size: 4
            key_map: default
            line_numbers: true
            line_wrapping: true
            display: Code
            type: code
            listable: hidden
      mode: table
      add_row: 'Add Code'
      reorderable: true
      display: 'Head Scripts'
      type: grid
      instructions: 'Add meta tags and scripts to the `<head>` area of your site.'
      listable: hidden
  -
    handle: footer_scripts
    field:
      fields:
        -
          handle: description
          field:
            input_type: text
            display: Description
            type: text
            listable: hidden
        -
          handle: code
          field:
            theme: material
            mode: htmlmixed
            indent_type: tabs
            indent_size: 4
            key_map: default
            line_numbers: true
            line_wrapping: true
            display: Code
            type: code
            listable: hidden
      mode: table
      add_row: 'Add Code'
      reorderable: true
      display: 'Footer Scripts'
      type: grid
      instructions: 'Add meta tags and scripts right before closing `</body>` area of your site.'
      listable: hidden

@austriker27
Copy link

Nice! THANK YOU! 🙏🏻🙏🏻

Also I think line 4 should have a handle title of head_scripts not grid ? 🤔

@jackmcdade
Copy link
Author

Yep, good catch.

@admench
Copy link

admench commented Jan 31, 2021

Here is the templating I made for it:

// shared/scripts.antlers.html:

{{ globals[scope] }}

<!-- {{ description }} -->
{{ code }}
<!-- end:{{ description }} -->

{{ /globals[scope] }}
// layout.antlers.html:

<head>
{{ partial:shared.scripts scope="head_scripts" }}
</head>

...

{{ partial:shared.scripts scope="footer_scripts" }}
</body>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment