added a comment -
13/Jul/10 9:53 AM Committed. I rewrote the code, didn't use chris's patch, but used the same basic approach. Method names may differ.
I did NOT provide a "facet_partial_name" method like Chris did; it's not needed, you can over-ride the new actual rendering method, #render_facet_limit(solr_field). I realized this approach was sufficient for my use case too, no need for the more complicated "configuration" option I had talked about at our meeting yesterday.
Here is an example of how you might over-ride that method to provide custom behavior for a certain facet:
module CustomFacetBehavior
def render_facet_limit(solr_field)
if ( solr_field == "my_special_field")
render(:partial => "my_special_thing")
else
super(solr_field)
end
end
end
# Use to_prepare to hopefully deal with cache_classes=false in development
Dispatch.to_prepare do
# Add our custom module to the controller(s) of choice with the "helper" method, which
# will cause the module to be added on _after_ automatically loaded helper modules, so
# it will be first in the call chain, can call super, etc.
CatalogController.send(:helper, CustomFacetBehavior)
end
I like the intent of this patch, but was unable to apply it. Chris, could you submit an updated test-passing patch for this? If so, I'll try to apply it again.