Forum

Thread tagged as: Problem, Runway, Blog

Runway Blog App: images in entries and listings not showing

In Runway Blog App - I'm trying to show a blog post image in both my post listing (blog/post_in_list.html) and post entry page (pages/post.php) using the template blog/post.html.

I can't work out why it won't show in either the listing or the entry. I have checked that an image has been uploaded and it shows in the admin area. I have referenced the documentation and I'm sure that the image field is correct. Both pages are using the templates. Everything else in the post shows without problems. #stumped

Post Entry Page

pages/post.php

<?php perch_blog_post(perch_get('s')); ?>

blog/post.html

            <perch:if exists="image">
                <img src="<perch:blog id="image" type="image" width="500" label="Image" order="6" />" alt="<perch:blog id="postTitle" escape="true" type="text" label="Title" />" />
            </perch:if>

Listing Page

blog/post_in_list.html

                    <perch:if exists="image">
                            <img src="<perch:blog id="image" type="image" width="500" />" alt="<perch:blog id="postTitle" escape="true" />" />
                    </perch:if>

pages/feed.php

    <?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;
        }
    ]);

    ?>
Dan Lee

Dan Lee 1 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

That looks ok to me. What does <perch:showall /> output?

Dan Lee

Dan Lee 1 points

Thats handy... This is what I get. perch_image is referencing the correct image.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Does your section template also have a field with ID image ?

Section details are loaded in so there could be a naming conflict.

Dan Lee

Dan Lee 1 points

I no longer have the image in the section template (I removed it). However when I remove the following section content elements from post_in_list.html and post.html the entry image does show.

<span class="cat__icon"><i class="ss-icon"><perch:blog id="sectionIcon" type="text" /></i></span>
<h4><perch:blog id="sectionTitle" type="text" /></h4>

Is there an appropriate way to include section content in those template files?

Drew McLellan

Drew McLellan 2638 points
Perch Support

Have you re-saved the section to update the data?

Dan Lee

Dan Lee 1 points

I have saved the template after making a change. What do you mean by re-saved the section?

Drew McLellan

Drew McLellan 2638 points
Perch Support

You'd added an image field with a conflicting ID to the blog section. Have you edited that section since to remove the conflicting content?

Dan Lee

Dan Lee 1 points

I deleted some of my old blog posts and it seemed to do the job. Thanks Drew.