variar / grav-plugin-unitegallery

Grav plugin to create image galleries with unitegallery js library
MIT License
19 stars 5 forks source link

Shortcode to use in markdown? #1

Open cpamcom opened 7 years ago

cpamcom commented 7 years ago

Hi I don't understand how to include a gallery in my modular. Does a shortcode exist?

variar commented 7 years ago

Hi, To create a gallery you should call unite_gallery function from some twig-template and use this template for your gallery page. I've added more examples to Readme.md. See if it helps.

I'll think about adding some markdown shortcode to simplify the process.

uwekoenig commented 5 years ago

Hi, I think I have a solution for this. Maybe you want to integrate this in the manual of the project.

Generate a file gallery_embedded.html.twig in your template templates/partials directory with the following content:

{% set myimages = null %}

{% set break = false %}
{% for p in page.children if not break %}
    {% if p.header.gallery_id == gal_id %}
      {% set myimages = p.media.images %}
      {% set break = true %}
    {% endif %}
{% endfor %}

<div class="gallery-container">
 {{ unite_gallery(myimages, '{"gallery_theme":"'~ page.header.unitegallery.gallery_theme ~'", "tiles_type":"'~ page.header.unitegallery.tiles_type ~'", "lightbox_show_textpanel": '~ page.header.unitegallery.lightbox_show_textpanel ~', "lightbox_textpanel_enable_description": '~ page.header.unitegallery.lightbox_textpanel_enable_description ~', "tile_enable_textpanel":'~ page.header.unitegallery.assets_in_meta ~', "grav_gallery_div_id":'~ gal_id ~'}') }}
</div>

Create subdirectories in your page like gallery1 and gallery2. Create in every subdirectory a file default.md with the following content:

default.md in /gallery1

---
gallery_id: 1
---

default.md in /gallery2

---
gallery_id: 2
---

When this is done enhance the header of your md-file and call the gallery in the content area like shown here:

---
title: Test
menu: Test123
unitegallery:
    gallery_theme: tiles   # tiles slider carousel compact default grid tilesgrid
    tiles_type: justified  # justified nested columns
    lightbox_show_textpanel: 'true' # value always in '...'
    lightbox_textpanel_enable_description: 'true' # value always in '...'
    tile_enable_textpanel: 'true' # value always in '...'
    assets_in_meta: true   # discable caching
---
My content here.

My first gallery

{% include 'partials/gallery_embedded.html.twig' with {'gal_id': 1} %}

My second gallery

{% include 'partials/gallery_embedded.html.twig' with {'gal_id': 2} %}