Forum
Displaying galleries in blog posts
Hi, I wonder if it is possible to display an image gallery within a blog post please.
I have a gallery working on the main page of my site
https://www.tailoryourholiday.com/gallery.html
I would like to be able to add specific galleries within blog posts. Different galleries would be shown on different posts. e.g here
https://www.tailoryourholiday.com/blog/2018-08-10-test-post
Not sure if it possible to do this.
I did find a reference to the following code, but I dont know where to use this (sorry for the simple questions I am quite new to using the more extended features of Perch)
<?php
perch_blog_custom([
'template' => 'post_in_list.html',
'each' => function($post) {
$blog_album = perch_blog_post_field($post['postSlug'], 'album', true);
$html = perch_gallery_album($blog_album, [
'count' => 4,
'template' => 'c_list_image.html',
], true);
$post['gallery_html'] = $html;
return $post;
}
]);
?>
Grateful if anyone can point me in the direction of suitable tutorial pages if it is possible. If this isn't possible could I use Perch blocks to allow the user to upload several images to a post to make a mini gallery?
Many thanks Vee Jones
Hi Vanessa,
I've found Perch repeaters good for image galleries - these work well wrapped up in blocks too so you can drop a gallery anywhere within the content. Using sub-templates, rescoped to parent, you can reuse both for normal content regions and other apps such as blog. Your image gallery mark up will vary.
_image_slider.html sub-template:
Perch blocks using sub-template above
Thanks I will have a try using your suggestion.
I have managed to get this working with your help thanks.
First I created a template blog-image-gal.html (templates – content )
I have a lightbox gallery set up in my site.
Then I used Perch blocks to call this into the post.html blog template (templates blog). I positioned this just below the main Post description I also added a content region using blogs so some text could be added below the gallery.
Thanks again for your help. Vee