MrDys / blacklight

Blacklight Plugin
http://projectblacklight.org/
Other
1 stars 1 forks source link

Move the facet block into a partial (with a render helper too) #416

Closed MrDys closed 12 years ago

MrDys commented 12 years ago

CODEBASE-220: I'd like to move the Blacklight facet display into a separate partial to allow local customization of the facets list (so implementors could use type-specific facet views as appropriate e.g. a date slider for temporal facets). Step one is to move the current facet display code into a separate partial.

I have done so in http://github.com/cbeer/blacklight/commit/fbec766ea94c9c7de8b94f6c9f32549cf1750f93 and in the attached patch.

MrDys commented 12 years ago

Original reporter: cbeer

MrDys commented 12 years ago

jrochkind: 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

MrDys commented 12 years ago

jronallo: I'm reassigning this one to me. 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.

MrDys commented 12 years ago

cbeer: Re-submitted a patch against 8b0652c00f9642fe90f12ae48d8f30628953ce15; sorry about that.