Kirby Gallery Plugin issue

Hi, guys, I am a tester, so I am rookie

i want to install kirby gallery plugin. I create fields folder than i moved gallery folder in it. i add blueprints in article.yml.

in panel side everything is perfect. i am able to upload pictures, select pictures quickly everything.

but in site side gallery is not showing

can you help me

Could you post your code from the article.php template where you are trying to fetch the images from the gallery field?

1 Like

Hi, thank you for your reply;

site/templates/article.php

<?php snippet('header') ?>



<main class="main" role="main">

    <div class="container">

        <?php if($site->articleLayout() == 'design1'): ?>

            <?php snippet('article/layoutDefault') ?>

        <?php else: ?>

            <?php snippet('article/layoutModern') ?>

        <?php endif ?>

    </div>

</main>



<?php snippet('footer') ?>

this is site/snippets/article/layoutDefault.php

<div class="row">
    <div class="col-12 col-md-9">
        <article class="mb-5">
            <?php if($img = $page->coverimage()->toFile()): ?>
            <a href="<?= $img->url() ?>" data-toggle="lightbox">
                <img class="img-fluid rounded mb-4" src="<?= $img->crop(825,516)->url() ?>" alt="<?= $img->alt() ?>">
            </a>
            <?php endif ?>
            <h1 class="h2"><?= $page->title() ?></h1>
            <?= $page->text()->kirbytext() ?>
        </article>
        <!-- Show articles tags -->
        <?php snippet('article/tags') ?>
        <hr>
        <!-- Show author -->
        <?php snippet('article/author') ?>
     	<hr>
        <!-- Show related articles -->
        <?php snippet('article/relatedArticles') ?>
    </div>
    <div class="col-12 col-md-3">
        <aside>
            <!-- Call aside modules -->
            <?php snippet('aside/socialbar') ?>
            <?php snippet('aside/about') ?>
            <?php snippet('aside/categories') ?>
            <?php snippet('aside/popularPosts') ?>
            <?php snippet('aside/tags') ?>
        </aside>
    </div>
</div>

and i want to show gallery in other page which is called default page
site/templates/Default.php

<?php snippet('header') ?>

<main class="main" role="main">
    <div class="container">
        <div class="row mt-4 justify-content-center">
            <div class="col-12 col-md-9">
                <h1 class="h2 mb-5"><?= $page->title() ?></h1>
                <?= $page->text()->kirbytext() ?>
            </div>
            <?php if($site->defaultLayout() == 'show'): ?>
            <div class="col-12 col-md-3">
                <aside>
                <!-- Call aside modules -->
                <?php snippet('aside/socialbar') ?>
                <?php snippet('aside/about') ?>
                <?php snippet('aside/categories') ?>
                <?php snippet('aside/popularPosts') ?>
                <?php snippet('aside/tags') ?>
                </aside>
            </div>
            <?php endif ?>
        </div>
    </div>
</main>

<?php snippet('footer') ?>

To get this right:

You don’t want to show the gallery in the article.php template, but in the default.php template? All galleries of all articles? The gallery of a single article? All images of all articles as a single gallery?

1 Like

Actually, i have 2 different article page. The first one is blog’s article page and the other one is default page so

I want to show gallery which is specific single gallery about per article,

Example :lets say if i write about nature, in the panel side i add pictures about nature and it should be shown in the gallery panel, or if i write about a city the gallery should show pictures I have already added regarding that city.

You can fetch the files from the field like so:

<?php

$gallery = $page->fieldname()->yaml(); // replace" fieldname" with name of your field

foreach($gallery as $imageName):

  if($image = $page->image($imageName)): ?>
    <img src="<?= $image->url() ?>">
  <?php endif ?>
<?php endforeach ?>
1 Like

thank you for solution sorry i am so rookie

which files in my template files or in gallery plugin files
:hugs:

i added this code in article page but nothing changed

<?php

$gallery = $page->gallery()->yaml(); // replace" fieldname" with name of your field

foreach($gallery as $imageName):

  if($image = $page->image($imageName)): ?>
    <img src="<?= $image->url() ?>">
  <?php endif ?>
<?php endforeach ?>

You would have to put that code into your templates, either article.php template or default.php template (or both)

thank you for your patience

but i added code and nothings changed?

I think I need more information. The easiest would be if you zip the project and send me a PM with a link, if you want.

thank you i send an email (info)

Ok, two issues:

  • In the code that you added to your default.php template, you call the field gallery, but the name of the field in your blueprint is pictures, so it must read:

11

<?php

$gallery = $page->pictures()->yaml(); // replace" fieldname" with name of your field

foreach($gallery as $imageName):

  if($image = $page->image($imageName)): ?>
    <img src="<?= $image->url() ?>">
  <?php endif ?>
<?php endforeach ?>
  • Secondly, you put the code into the default.phptemplate, but all your articles use the articles.php template (i.e. all subpages of the blog folder have an article.txt file in it and that means that the content is rendered with the template of the same name). If you put the above code into your article.php template, the files should show up in the “Life is a journey” article (the other two don’t have any pictures saved yet):

thank you for your interest firstly

secondly i think i will buy a personal licences. İs there any christmas discount about future :slight_smile:

No, currently there are no discounts at all available (there are no discounts for the personal license, anyway).

ok i got it thank you

The code looks a bit messy, there seems to be a space missing between the opening php tag and the $gallery variable. Your code should look something like this (depending on where you want your images to show up)

<?php snippet('header') ?>
<?php 
$gallery = $page->pictures()->yaml();

foreach($gallery as $imageName):

  if($image = $page->image($imageName)): ?>
    <img src="<?= $image->url() ?>">
  <?php endif ?>
<?php endforeach ?>

<main class="main" role="main">
    <div class="container">
        <?php if($site->articleLayout() == 'design1'): ?>
            <?php snippet('article/layoutDefault') ?>
        <?php else: ?>
            <?php snippet('article/layoutModern') ?>
        <?php endif ?>
    </div>
</main>

<?php snippet('footer') ?>

Note that your images will turn up big in the browser, you would have to add some more HTML Markup to make it look nice.

wooow what a support. thankyou