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.

Themes & Styling

Quark Child: Masonry-like Gallery

first-time

Solved by Amaury Hanser View solution

Started by Starguest 6 years ago · 8 replies · 735 views
6 years ago

Hello World,
im pretty new to this stuff and i could need some help. Im trying to implement a masonry like gallery (colcade.js, same author) but its not working and i feel like its because of the template. I cant find a solution thats why im asking for help. It worked outside of grav in a simple html file.

Here is what ive done so far

gallery.html.twig
https://pastebin.com/U6DmAkhY

css
https://pastebin.com/c8ynYGx7

Thanks in advance
❤️

last edited 06/19/20 by Starguest
6 years ago

@Starguest, Would you mind sharing what "not working" means?

6 years ago

Hello,

When you open your dev tool console, do you see any error?
I'm asking because I wonder if:

HTML
<script>
var colcade = new Colcade( '.dz-grid', {
    columns: '.dz-grid-col',
    items: '.dz-grid-item'
});
</script>

Shoudln't be declared after you load colcade.js.

6 years ago

Sorry,
I was talking about the dev tool console of your browser.
F12 to open it on chrome or firefox, then click on the console tab.

6 years ago

Oh, found something.

ReferenceError: Colcade is not defined

6 years ago Solution

Yep, so my guess was right.

You are adding colcade.js at line 13

TWIG
{% block javascripts %}
    {{ parent() }}
    {% do assets.addJs('theme://js/colcade.js', {group:'bottom'}) %}

{% endblock %}

In your HTML, the group "bottom" is probably just before de body tag is closed.

But you are declaring a new Colcade in the head tag, line 19

HTML
<script>
var colcade = new Colcade( '.dz-grid', {
    columns: '.dz-grid-col',
    items: '.dz-grid-item'
});
</script>

Colcade is not loaded yet as your THML document is read from top to bottom.

You should either move where you declare your Colcade or where you load Colcade.js

👍 1
6 years ago

Well, problem solved.

Thanks a lot 😘

Suggested topics

Topic Participants Replies Views Activity
Themes & Styling · by Pedro M, 2 months ago
4 193 2 months ago
Themes & Styling · by Ian, 2 months ago
3 90 2 months ago
Themes & Styling · by Norbert, 2 years ago
11 449 3 months ago
Themes & Styling · by Lukáš Findeis, 3 months ago
0 44 3 months ago
Themes & Styling · by Sebadamus, 4 months ago
5 123 3 months ago