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

Error/bug when selecting multiple images with pagemediaselect

Started by Muut Archive 10 years ago · 3 replies · 479 views
10 years ago

Hi, I've got a problem with selecting multiple images with the pagemediaselect field. If I enable


multiple: true

TXT

in my blueprint file and then pick multiple images with it. I get this error

 [twig error](//muut.com/u/getgrav/s3/:getgrav:iAiP:knipsel.png.jpg) 

This is my complete blueprint file

extends@: default

form:
fields:
tabs:
fields:
referenties:
type: tab
title: Referenties
fields:
header.referenties:
type: list
fields:
.image:
type: pagemediaselect
label: image
multiple: true

TXT


Am I doning something wrong or is it a bug?
10 years ago

Hi,

From my perspective, what you want to achieve is to add several "referenties" with each having one image.

It's what I do wiyh my showcase example below. Contributors will create n "block" for which he will select 1 image, set 1 url and set 1 text.

YAML
title: Showcase
'@extends': default

form:
  fields:
    tabs:
      fields:
        advanced:
          fields:
            columns:
              fields:
                column1:
                  fields: 
                    name:
                      default: modular/showcase
                      '@data-options': '\Grav\Common\Page\Pages::modularTypes'
            overrides:
              fields:
                header.template:
                  default: modular/showcase
                  '@data-options': '\Grav\Common\Page\Pages::modularTypes'
        buttons:
          type: tab
          title: Buttons
          fields:
            header.buttons:
              name: buttons
              type: list
              label: Buttons
              fields:
                .text:
                  type: text
                  label: Text
                .url:
                  type: text
                  label: URL
                .img:
                  label: Choose media
                  type: pagemediaselect

As it's a type: list, you will have 0 to n occurences of this "block". Each block will have a 3 items combination (1 text, 1 url, 1 image).

Is it what you exepect or do you exepect to add several images per "block" ?

10 years ago

Hi, thanks for replying.

You almost got it, except they have to be able to upload multiple images per 'block'. So for each block 1 title and multiple images that will form a gallery.

10 years ago

Hi,

Ok so I didn't meet your use case yet.

Ok, for a gallery, I just built, I used this strategy:

  • create a album_list blueprint with related template (clone of default.yaml)
  • create a album blueprint with related template (clone of default.yaml with a few custom fields to manage remote albums)

Album_list page will display all the available albums with 1 image describing the album.
In each album, each photo is a media of the page.

So quite easy :)

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1357 9 years ago
Archive · by Muut Archive, 9 years ago
2 936 9 years ago
Archive · by Muut Archive, 9 years ago
2 4066 9 years ago
Archive · by Muut Archive, 9 years ago
1 2954 9 years ago
Archive · by Muut Archive, 9 years ago
3 1120 9 years ago