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?
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.
<?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 ?>
which files in my template files or in gallery plugin files
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 ?>
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:
<?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):
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)