<p>Another option is to create a <code>galleryImage</code> channel (with <em>Entries in this section have their own URLs</em> <strong>not</strong> checked), and then make your matrix block be a collection of entries in <code>galleryImage</code> added via an <a href="http://buildwithcraft.com/docs/entries-fields" rel="nofollow">Entries</a> field. Each <code>galleryImage</code> would have the image, caption, etc.</p>

CC BY-SA 3.0
2014-08-11T08:33:18.137Z
That sounds a pretty flexible solution I'd not thought of, thanks!
Matt Wilcox
CC BY-SA 3.0
2014-08-10T19:16:45.103Z
2014-08-10T19:29:33.340Z
2014-08-10T19:29:33.340Z
Marion Newlevant
<p>I guess it depends on what information each Asset needs to contain. As you mentioned, a Matrix within a Matrix is not possible, so you will need a different method to attach additional information to each Asset.</p>

<p>One method that may work is to create <a href="http://buildwithcraft.com/docs/assets#asset-meta-fields">Asset Meta Fields</a> for Assets. This way, you can define additional things on each image on the Asset level. For example, you could have custom fields for things like title, description, copyright, etc.</p>

<p>With Asset Meta Fields in place, you could define one "Gallery" Matrix block that allows for multiple files to be selected. The order could be controlled by drag/dropping each of the selected Assets.</p>

CC BY-SA 3.0
2014-08-10T14:04:04.050Z
2014-08-10T14:04:04.050Z
Chad Clark
<p>What's the best solution for having a 'gallery' block inside of a Matrix? By 'gallery block' I mean an ability to have multiple images, with captions, alt, and link, presented as a gallery on the front-end, but as part of a parent Matrix (the user needs to control the location of the gallery within the page content, so the page content is a Matrix).</p>

<p>What I really need is a Matrix within a Matrix, but that's not possible with Craft at the moment. I'd thought using a Table type inside the Matrix might work, but Craft doesn't offer Asset as a type for use inside a Table (makes sense, this would be a hacky use of 'table').</p>

<p>Another work-around might be to just have 'singular image' blocks and have the Template code notice when multiple Image blocks occur as siblings, and convert those into gallery mark-up - but I've no idea how to code that, if it's even possible.</p>

<p>Do you have better solutions?</p>

CC BY-SA 3.0
2014-08-10T18:42:03.357Z
If you do go the "sibling blocks" route, check out [this thread here...](http://craftcms.stackexchange.com/q/1745/45)
Lindsey D
<matrix><gallery>
Gallery block inside a Matrix
# Gallery block inside a Matrix

(Asked by: username_0 on 2014-08-10)

What's the best solution for having a 'gallery' block inside of a Matrix? By 'gallery block' I mean an ability to have multiple images, with captions, alt, and link, presented as a gallery on the front-end, but as part of a parent Matrix (the user needs to control the location of the gallery within the page content, so the page content is a Matrix).

What I really need is a Matrix within a Matrix, but that's not possible with Craft at the moment. I'd thought using a Table type inside the Matrix might work, but Craft doesn't offer Asset as a type for use inside a Table (makes sense, this would be a hacky use of 'table').

Another work-around might be to just have 'singular image' blocks and have the Template code notice when multiple Image blocks occur as siblings, and convert those into gallery mark-up - but I've no idea how to code that, if it's even possible.

Do you have better solutions?

**Tags:** matrix, gallery
> **Comments:**
> **username_1**: If you do go the "sibling blocks" route, check out [this thread here...](http://craftcms.stackexchange.com/q/1745/45)  

---

## 2 answers

### Answer by username_2 on 2014-08-10. Score: 3 | Accepted answer

Another option is to create a `galleryImage` channel (with *Entries in this section have their own URLs* **not** checked), and then make your matrix block be a collection of entries in `galleryImage` added via an [Entries](http://buildwithcraft.com/docs/entries-fields) field. Each `galleryImage` would have the image, caption, etc.

> **Comments:**
> **username_0**: That sounds a pretty flexible solution I'd not thought of, thanks!  

---

### Answer by username_3 on 2014-08-10. Score: 6

I guess it depends on what information each Asset needs to contain. As you mentioned, a Matrix within a Matrix is not possible, so you will need a different method to attach additional information to each Asset.

One method that may work is to create [Asset Meta Fields](http://buildwithcraft.com/docs/assets#asset-meta-fields) for Assets. This way, you can define additional things on each image on the Asset level. For example, you could have custom fields for things like title, description, copyright, etc.

With Asset Meta Fields in place, you could define one "Gallery" Matrix block that allows for multiple files to be selected. The order could be controlled by drag/dropping each of the selected Assets.


---

