Your theory is correct – the Smarty variables get assigned before the templates get rendered, so they are overwriting one another.  I can’t think of a simple way to do this in 1.x without either duplicating code (i.e. use different variable names for different copies of the same module, as you suggested) or significantly changing the workflow for recommendation rendering (i.e. immediately render the templates to an array of HTML snippets in the search object’s getRecommendationsTemplates() method instead of passing an array of template names to render).  This shouldn’t be a problem in 2.0 because each recommendation module gets rendered in its own separate context… but I realize that doesn’t help you right now with the legacy code!

 

- Demian

 

From: Ronan McHugh [mailto:rmchugh@nli.ie]
Sent: Monday, October 01, 2012 11:53 AM
To: vufind-tech@lists.sourceforge.net
Subject: [VuFind-Tech] Can't display more than one SideFacets Recommendation per page

 

Hello,

 

I’m working on a new browse-esque interface which will present users with multiple routes into the catalogue based on the idea of a “Generous Interface” (http://www.slideshare.net/mtchl/generous-interfaces) similar to the European Library’s Discover Portal (http://www.theeuropeanlibrary.org/tel4/discover). The basic way I’m doing this is through recommendation modules, including facets. These facets are derived through an empty search of the collection. In order to make the interface look nice, I want to have the facets in different zones, rather than simply a long line of text on the side of the page. So, I’ll have one set of facets for format, one set of facets for genre, each in a different box on the page.

 

In my searches.ini I have something like this:

 

[DiscoverRecommendations]

AllFields[]          = SideFacets:DiscoverA

AllFields[]          = SideFacets:DiscoverB

 

With corresponding sections in my facets.ini file:

 

[DiscoverA]

format             = Format

[DiscoverB]

genre_facet        = Genre

 

I then call these recommendations in my Discover.php and assign them to the interface. However, for some reason, the interface displays two copies of one facet rather than one of each. What’s worse, when I try to run a normal search, the facets from the Discover interface are being displayed, rather than the facets for my normal Search from the [Results] section in facets.ini. Attached is a screenshot to make this somewhat more understandable.

 

I have tried a bit of debugging and found that the parameters are being passed in fine to the module and thence to Solr, so I think what might be happening is that smarty is getting a bit confused about the variables being passed in. If I try to do one TopFacets and one SideFacets it seems to work ok. If this is a smarty thing, I guess the only way I can fix it is by creating a secondary template and assigning some variables to that, but that sounds messy. Does anyone know what might be going on and have some ideas for fixing it?

 

Thanks,

 

Ronan

 

Visit our free exhibitions

___________________________________________

Tabhair cuairt ar ?r dtaispe?ntais saor in aisce

The contents of this e-mail (including attachments) are private and confidential and may also be subject to legal privilege. It is intended only for the use of the addressee. If you are not the addressee, or the person responsible for delivering it to the addressee, you may not copy or deliver this e-mail or any attachments to anyone else or make any use of its contents; you should not read any part of this e-mail or any attachments. Unauthorised disclosure or communication or other use of the contents of this e-mail or any part thereof may be prohibited by law and may constitute a criminal offence. If you receive this e-mail by mistake please notify the system manager @ 6030219.

T? an r?omhphost seo (agus aon iat?n a ghabhann leis) pr?obh?ideach agus r?nda agus d?fh?adfadh go mbeadh eolas inti at? faoi phribhl?id dhl?thi?il. N? ceadmhach ?s?id an r?omhphoist seo d??inne ach don t? ar seoladh chuige ?. Mura duitse an r?omhphost seo n? an t? at? freagrach as ? a sheoladh, t? cosc ar ch?ipe?il agus ar sheachadadh an r?omhphoist seo agus aon iat?n a ghabhann leis chuig ?inne n? ?s?id a bhaint as a bhfuil ann; n? ceart an r?omhphost seo n? aon iat?n a l?amh. D?fh?adfadh go mbeadh cosc ioml?n dl?thi?il ar sceitheadh n? comhfhreagras n? aon ?s?id eile gan chead ar a bhfuil sa r?omhphost seo agus d?fh?adfadh s? a bheith ina chion coiri?il. M? fuair t? an r?omhphost seo tr? earr?id, d?an teagmh?il le bainisteoir an ch?rais @6030219