Forum
Adding Gallery Album to Blog post
I was able to use the album list field type to select a gallery album on pages and then get that album to display on those pages, but I haven't been able to do the same for blog posts. This is what I have...
I added this to post.html:
<perch:blog id="album" type="albumlist" label="Blog Gallery" suppress="true" order="5" />
And this to the single blog page:
<?php
$album = perch_blog_custom(array('skip-template'=>true));
if (is_array($album)) {
// ['album'] is the ID of the field to get the slug from
$albumSlug = $album[0]['album']['albumSlug'];
perch_gallery_album($albumSlug);
}
?>
Any ideas on where I've gone wrong?
What result do you get?
I managed to get the gallery to output, but it's not getting the correct gallery - it just returns the first gallery every time no matter what is selected. I turned on debugging and I see this line in the SQL:
That albumSlug is the same for all blogs even though different albums have been selected via the albumlist selector.
I assume this means this line is incorrect?
This is the array output...
Are you trying to output one blog post or a list of them?
Just 1 blog post. This is the code on the single blog page...
Actually, I got it working using the following. Is there anything wrong with this method?
That's fine. The problem with the original code was that your weren't filtering it to the post you wanted.