Problems, need help? Have a tip or advice? Post it here.
8 posts Page 1 of 1
Hi,

I am trying to add images (Thumbnails) to the Search result page.

Problem: the images don't clear themselves between rounds. If there's no image, it repeats the former image, but don't clear the variable.
I have two variables for the thumbnails (depending on the type of file): gg_thumb and thumb

What do I do wrong?

<cms:if gg_thumb><img src="<cms:show gg_thumb/>" width="100" />
<cms:else/>
<cms:if thumb><img src="<cms:show thumb/>" width="100" />
<cms:else/>&nbsp;
</cms:if>
</cms:if>
Please style the code with the button :)

Put this to debug the problem:
Code: Select all
<cms:if gg_thumb>
   gg_thumb:"<cms:show gg_thumb/>"
<cms:else_if thumb />
   thumb:"<cms:show thumb/>"
<cms:else/>&nbsp;
</cms:if>

Probably you'll see something unexpected?
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
Hi, and thanks for your reply.

It doesn't work. It collects exactly the same addresses.

I think the problem is that it doesn't clear the addresses between rounds.

For the time being the code looks like that:

Code: Select all
<cms:search limit='50'>
                                <cms:if k_paginated_top >
                                    <div>
                                        <cms:if k_paginator_required >
                                            Page <cms:show k_current_page /> sur <cms:show k_total_pages /><br>
                                        </cms:if>
                                        <cms:show k_total_records /> Pages trouvées -
                                        affichant: <cms:show k_record_from />-<cms:show k_record_to />
                                    </div>
                                </cms:if>
                           
                               <h3 style="background-color:#f7f7f7; margin:10px 0; padding: 0px 20px 5px; border-bottom:3px #ff8000 solid; box-shadow:1px 1px 3px #ccc; -moz-box-shadow:1px 1px 3px #ccc; -webkit-box-shadow:1px 1px 3px #ccc; ">
                                 <a href="<cms:show k_page_link/>"><cms:show k_search_title /></a></h3>
                                   
                                <cms:paginator />
                           
                            </cms:search>   


I'll be damned, I never paid attention to the code button!!! :)
@PaoloE, could you please let me know which version of Couch you are using?
Also, could you please PM me the template in question (containing editable regions definitions and the problem code used for display)? I'd like to test it out myself.

Thanks.
Hi KK,

ok, thanks.

I think I use the last version of Couch. (I updated a month ago)

I am sending the files now.

Cheers
Paolo, I think I can see what seems to be happening.

<cms:search> (unlike <cms:pages>) can fetch results (i.e. pages) from multiple templates.
Several variables made available by search are common for all templates. However, the custom fields are template specific.

So, if (as in your case), we need to display these custom variables, it'd be necessary to first make sure as to which template the fetched page belongs to. As an example, following first checks if the template is 'gallery.php' before trying to show the 'gg_thumb' variable which is gallery specific (and likewise for the blog template) -
Code: Select all
<cms:search>
    <cms:if k_template_name='gallery.php' >
        <cms:if gg_thumb>
            <img src="<cms:show gg_thumb />" width="100" alt="<cms:show k_search_title />" />
        </cms:if> 
    </cms:if>     

    <cms:if k_template_name='blog.php' >
        <cms:if thumb/>
            <img src="<cms:show thumb />" width="100" alt="<cms:show k_search_title />" />
        </cms:if> 
    </cms:if>         
</cms:search>

Could you please try to modify your code as indicated and let me know if it helps?

Thanks.
That actually make sense!

and it works!!! :)

Thanks a lot KK (again!)

Have a wonderful day.
Paolo
You are welcome :)
8 posts Page 1 of 1