Giter Site home page Giter Site logo

statamic-accordion-group's Introduction

Statamic Accordion Group

Stash groups of fields from long fieldsets away in accordion-style toggle boxes.

Installation

To install this fieldtype, download the addon files from the Statamic marketplace and place the AccordionGroup folder in your site/addons directory. You should then be able to add 'Accordion Group' fields to your fieldsets.

Setting up fieldsets

You will need to define fieldsets for groups of fields that you wish to place within an accordion group, once a fieldset has been built you can tell you accordion group to use that fieldset, either through the field 'extras' interface or in your yaml.

Example

In the example below we are storing fields from the 'metadata' fieldset in an accordion group:

fields:
  metadata:
    type: accordion_group
    display: Metadata
    instructions: Optimize the metadata for this page or post.
    child_fieldset: metadata

Example metadata field in CP

How do I use this in my templates?

In templates the fields contained within accordion groups will be prefixed with the name of the group, for example the meta_title field will become metadata.meta_title:

{{ if metadata.page_no_index }}
<meta name="robots" content="noindex,nofollow" />
{{ /if }}
<title>{{ metadata.meta_title or title }}</title>
<meta name="description" content="{{ metadata.meta_description }}" />

Nesting?

Yes, but not recommended when your child fieldset contains the parent accordion field.

statamic-accordion-group's People

Contributors

andrewhaine avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Forkers

liam-wholegrain

statamic-accordion-group's Issues

A few improvements

image
Image speaks louder than words.

  • Repeated title and instructions
  • No padding on the fieldset fields

EDIT:
This works flawlessly when it's not in a replicator.
In the screenshot, the accordion_group is added to a replicator.

Fix for Padding

add this to line 91.

    fieldClasses(field) {
      return [
        "form-group",
        "p-2",
        field.type + "-fieldtype",
        tailwind_width_class(field.width),
        field.classes || ""
      ];
    }

Not sure how we can fix the ReplicatorSet generated headers without changing the name for instruction and title.

Conditionals not working within accordion group

Thanks for creating this addon. I have used it in a few projects and it works great to keep the editor clean. However, it seems that using conditionals on fields doesn't work within an accordion group.

For example, I have a simple show of two fields when selecting banner_type for color and image. Both fields end up showing within the accordion group when it should only be showing one field depending upon the selection made to banner_type. The same example works fine when loading it via a partial.

Here the example code:

banner_type:
  options:
    color: Color
    image: Image
  type: select
  default: image
  display: Banner Type
banner_color:
  type: colorpicker
  localizable: true
  width: 33
  display: Background Color
  show_when:
    banner_type: color
banner_image:
  container: main
  folder: /
  restrict: false
  type: assets
  localizable: true
  width: 33
  display: Background Image
  max_files: 1
  mode: grid
  show_when:
    banner_type: image

Screenshot of the accordion group:
image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.