Problems, need help? Have a tip or advice? Post it here.
3 posts Page 1 of 1
hi all,
I'm creating a search results page which is to search all the posts from different templates on the same domain, but I'm running into an oddity in which an editable field value of one post shows up again in a next post (from a different template, which doesn't have that editable field).

I have two templates at the moment, one "editorial.php" which consists of editorial articles, and one "article.php" which consists of articles by various guest authors, whose names I enter into an editable field.
The search result for the second type of article should display the author name, the result for the first should simply not display anything there.

What I'm noticing is that, using the cms:search tag, the value of the author field appears to stay in place when displaying the next result.

I think this does not happen when using the cms:pages-tag to produce a similar multi-template list, but I'm not sure why it happens with cms:search? Am I doing something else wrong?

What way would there be to throw out any remaining values before the display of the next result (from a template which doesn't have that same editable field)?

This is the code I'm using to display the results:

Code: Select all
<cms:search limit='10' keywords="<cms:gpc 's' />" >
    <h1><a class="" href="<cms:show k_page_link />"><cms:show k_search_title /> / <cms:show og_auteur/></a></h1>
   
    &laquo;&nbsp;<cms:show k_search_excerpt />&nbsp;&raquo;
   
</cms:search>


Thanks in advance for the trouble of thinking along.

edit - I was thinking if perhaps there is a variable (available within the cms:search tag) that expresses the "template of origin" of each separate search result, to use that to specify a different style of output per template, leaving out the variables of the other templates.
Hi,

Following is a sample check that may be used before outputting a variable belonging exclusively to a particular template -
Code: Select all
<cms:if k_template_name='article.php'><cms:show og_auteur/></cms:if>

Hope this helps.
Hi KK,
Pardon for not checking back until now, but thank you for the answer, I will try that out.

best,
T
3 posts Page 1 of 1