Blacklight Plugin

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

Details

  • Type: Improvement Improvement
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: None
  • Fix Version/s: 2.6
  • Component/s: None
  • 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.
    Show
    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.
  1. CODEBASE-220.patch
    (4 kB)
    Chris Beer
    02/Jun/10 10:20 AM

Activity

Hide
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.
Show
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.
Hide
Chris Beer added a comment - 02/Jun/10 10:21 AM
Re-submitted a patch against 8b0652c00f9642fe90f12ae48d8f30628953ce15; sorry about that.
Show
Chris Beer added a comment - 02/Jun/10 10:21 AM Re-submitted a patch against 8b0652c00f9642fe90f12ae48d8f30628953ce15; sorry about that.
Hide
Jonathan Rochkind 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
Show
Jonathan Rochkind 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

People

Dates

  • Created:
    04/May/10 11:24 AM
    Updated:
    13/Jul/10 9:53 AM
    Resolved:
    13/Jul/10 9:53 AM