Blog image not being returned in search

  • Hello,


    I have the following code in the search results template:


    Code
    1. <perch:if exists="image">
    2. <div class="image">
    3. <div class="imageHolder">
    4. <perch:template path="content/image_responsive.html" rescope="parent"></perch:template>
    5. <span></span>
    6. </div><!--/.imageHolder-->
    7. </div><!--/.image-->
    8. </perch:if>


    The blog post template contains the following code:


    Code
    1. <img src="<perch:blog id="image" type="image" width="320" height="240" crop="true" label="Image" order="4" />" alt="<perch:blog id="postTitle" />" />


    However the image is not being returned in the search results. This works fine for all other results with an image id, any reason why the blog image would not be returned?

  • Here's another one to add into the mix:


    The following code returns blog posts in search:

    PHP
    1. <?php $query = perch_get('q'); perch_content_search($query, array( 'count'=>12, 'apps' => ['PerchBlog')); ?>

    However the following code does not if multiple pages are matched to a term, shop items are include, content items are included but blog posts are omitted?:

    PHP
    1. <?php $query = perch_get('q'); perch_content_search($query, array( 'count'=>12, 'apps' => ['PerchBlog','PerchShop','PerchContent'] )); ?>
  • Is it possible to combine two sets of results into one?


    This code shows the blog post results, then everything else:


    PHP
    1. <?php $query = perch_get('q'); perch_content_search($query, array( 'count'=>12, 'apps' => ['PerchBlog'], )); ?>
    2. <?php $query = perch_get('q'); perch_content_search($query, array( 'count'=>12, 'apps' => ['PerchBlog','PerchShop','PerchContent'], )); ?>

    It would be great if I could combine them into one paginated set of results.

  • However the image is not being returned in the search results. This works fine for all other results with an image id, any reason why the blog image would not be returned?


    Each app implements its own search handler. The Blog app's search handler does not all fields.


    As a workaround you can use a Perch layout inside the template, pass an identifying field to the layout and then use perch_blog_custom() to output the post. See Use The Image In A Blog Post In Search Results