trilbymedia / grav-plugin-flex-objects

Powerful and supremely flexible object support for Grav
MIT License
38 stars 10 forks source link

How to control the foldername of objects #152

Open Jogai opened 2 years ago

Jogai commented 2 years ago

I switched to folderstorage, but each directory is named like a hash. If I configure the key to one of my fields it errors on save saying "Failed to save entry: Array to string conversion"

relevant part of my config:


  # Data Configuration
  data:
    # Object class to be used, allowing custom methods for the object
    object: 'Grav\Common\Flex\Types\Generic\GenericObject'
    # Collection class to be used, allowing custom methods for the collections
    collection: 'Grav\Common\Flex\Types\Generic\GenericCollection'
    # Index class to be used, works as a quick database-like lookup index
    index: 'Grav\Common\Flex\Types\Generic\GenericIndex'
    storage:
      # Storage class, use single file storage (does not support images and assets)
      class: 'Grav\Framework\Flex\Storage\FolderStorage'
      options:
        formatter:
          # File formatter class, in this case the file is stored in markdown
          class: 'Grav\Framework\File\Formatter\MarkdownFormatter'
        # JSON file where all the objects will be stored
        folder: user-data://flex-objects/crashes
        # File pattern to generate the filename
        pattern: '{FOLDER}/{KEY}/{FILE}{EXT}'
        # Filename
        file: {key}
        # Field which will be used as {KEY}
        key: crash_id
        # Keep index file in filesystem to speed up lookups
        indexed: true