Hi!

In "sesam.no" we have a template "newsRelatedCases.vm". This template is used to print a list with news cases belonging to a news search. These news cases are fetched through navigators in fast.

A snippet from the template:

...
#set($searchResults = $datamodel.getSearch('newsSearchCasePersonNavigator').results)
#set($hitCount = $searchResults.hitCount)
#set($relatedCases = $datamodel.navigation.getNavigation('cases').results)
...
#relatedCasesOutput($hitCount $relatedCases)
...
#macro(relatedCasesOutput $hitCount $relatedCases)
    #foreach($relatedItem in $relatedCases)
        ## Don't show the displayed news case, if any.
#if (!($type.equals('sak') && $currentCase.equals("#urlencode($relatedItem.title)"))) ## Removing case navigators with less than 2% hits in articles
            ## Avoid business rules in templates?
            #set ($minCount = (($hitCount * 2) / 100))
#if ($relatedItem.hitCount < 0 || $relatedItem.hitCount > $minCount)
                #if ($casesCount == $myCount)
                    </div>
                    <divid="cases_botbox"style="display:none;">
                #end

                #set ($casesCount = $casesCount + 1)
#newsNavigationLink($relatedItem "#chopString($relatedItem.title, 50)"
                        "category:navigation;subcategory:sak")<br/>
            #end
        #end
    #end
#end
...

As you see, the template contains logic to remove the current news case you are displaying search results for, if you're in a newscase mode, and there's also logic not to include a news case if it has too few results. The same logic is placed in an xml-template.

I would really to this logic somewhere else, i.e. in a result hander.

What do you think is the proper solution?

Can I use a result handler to modify the navigator result so the unwanted list items are removed, and then the templates can just print the news cases that still are in the result list?

--
ENDRE MIDTGÅRD MECKELBORG
Senior Developer
Schibsted Søk AS
sesam.no

_______________________________________________
Kernel-development mailing list
[email protected]
http://sesat.no/mailman/listinfo/kernel-development

Reply via email to