Issue Details (XML | Word | Printable)

Key: CODEBASE-220
Type: Improvement Improvement
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: Jonathan Rochkind
Reporter: Chris Beer
Votes: 0
Watchers: 0
Operations

Clone this issue
If you were logged in you would be able to see more operations.
Blacklight Plugin

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

Created: 04/May/10 11:24 AM   Updated: 13/Jul/10 09:53 AM
Return to search
Issue 16 of 22 issue(s)
<< Previous | CODEBASE-220 | Next >>
Component/s: None
Affects Version/s: None
Fix Version/s: 2.6

File Attachments: 1. Text File CODEBASE-220.patch (4 kB)



 Description  « Hide
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.

 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Jason Ronallo added a comment - 30/May/10 12:05 AM
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.

Chris Beer added a comment - 02/Jun/10 10:21 AM
Re-submitted a patch against 8b0652c00f9642fe90f12ae48d8f30628953ce15; sorry about that.

Jonathan Rochkind added a comment - 13/Jul/10 09: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