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

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Support

Images don't show up in UniteGallery page

Solved by pamtbaau View solution

Started by Ton Haarmans 6 years ago · 10 replies · 1334 views
6 years ago

I am quite new with Grav. I have set up a blog page which contains a unitgallery container. The container appears, but the images are not shown. so probably the script can't find the images. The documentation of the gallery shows where to place the images for a modular page, but not for a non-modular page... How should I do it???

6 years ago

You can set up a modular page and inject its content into a regular page:

{{ page.find('/_my_modular_page').content() }}

6 years ago

Thank you for your answer!
should I do that in the markdown file (item.md) or in a template file?
And where would I place the modular page?

Sorry, I am a complete newbe

last edited 01/22/20 by Ton Haarmans
6 years ago

Place this line in the page's content, there where the gallery should appear.
Just save the modular page under some name and replace /_my_modular_page with that name. Preserve the trailing slash and underscore when doing this.

6 years ago

Probably I am still doing something wrong, but the images do not appear. I do have a container field and a loading gif...but nothing happens...

Folder structure:
...
04.articles

  • 03.sneeuw
    • Pictures
    • Item.md
    • modular.md

In modular.md I have:

title: gallery
content:
items: @self.modular

In item.md I have:

title: Sneeuw!
body_classes: 'no-hero onderwerpen gallery blog'
assets_in_meta: true
unitegallery:
gallery_theme: tiles

In blog-item.html.twig I have
...
<div class="e-content">
<div class="gallery-container {{ page.header.class }}">
{{ unite_gallery(page.media.images, '{"gallery_theme":"' ~ page.header.unitegallery.gallery_theme ~ '"}') }}
</div>
{{ page.content|raw }}
{{ page.find('/_gallery').content() }}
</div>
...

6 years ago

@TonHaarmans:
_gallery'

Does this modular page exist ?

I assume your modular page is modular.md.

So this should be
{{ page.find('/_modular').content() }}

6 years ago

Then it might be a problem with the gallery plugin itself. Maybe some UniteGallery-experienced user can help out here?

6 years ago

Ok, Thanks Harald, so far.
BTW, I can always do it without plugin and use the original scripts and styles...

6 years ago Solution

@TonHaarmans, Following the README of the plugin:

  • Installed plugin: $ bin/gpm install unitegallery
  • Added config to header of page '/pages/01.home/default.md'
    YAML
    ---
    title: Home
    body_classes: title-center title-h1h2
    unitegallery:
    gallery_theme: tiles
    ---
    
  • Added the Twig snippet to '/user/themes/quark/templates/default.html.twig':

    TWIG
    {% extends 'partials/base.html.twig' %}
    
    {% block content %}
    <div class="gallery-container {{ page.header.class }}">
        {{ unite_gallery(page.media.images, '{"gallery_theme":"' ~ page.header.unitegallery.gallery_theme ~ '"}') }}
    </div>
    
    {{ page.content|raw }}
    {% endblock %}
    
  • Added images to folder '/pages/01.home`
  • Launched browser:
    image|665x281

Notes:

  • Don't paste Twig snippet into Quark templates, but use an inherited theme, else you will loose all changes when updating Quark..
  • You probably want to create a specific page template for the gallery. E,g '/user/themes/mytheme/templates/gallery.html.twig' and paste Twig snippet in there.
    Then create a new page named 'gallery.md'.
  • My config:
    • Clean Grav installation: v1.7.0-rc.3.
    • Theme Quark

Hope this helps...

last edited 01/22/20 by pamtbaau

Suggested topics

Topic Participants Replies Views Activity
Support · by Thomas, 1 week ago
2 56 13 hours ago
Support · by Anna, 3 days ago
2 61 16 hours ago
Support · by Justin Young, 17 hours ago
1 32 17 hours ago
Support · by Duc , 1 week ago
2 66 5 days ago
Support · by Colin Hume, 1 week ago
2 59 5 days ago