Ok, I can't find the solution to this problem. I have implemented the  
suggestion from Oliver [http://lists.radiantcms.org/pipermail/radiant/ 
2007-May/004927.html] to control extension load order, but my  
customized render call isn't overwriting the default SearchPage one.  
When I look at the debug log I only see the call for Page.find. I  
went into Console and confirmed that CatalogSearchExtension is being  
included via 'SearchPage.include? CatalogSearchExtension' so am I  
missing something?

=== /catalog_extension.rb SNIPPET ===
   [... SNIP ...]

   def activate
     admin.tabs.add "Catalog", "/admin/catalog", :after =>  
"Pages", :visibility => [:all]

     CatalogPage

     require_dependency 'search_extension'

     SearchPage.send :include, CatalogSearchExtension
   end

   [... SNIP ...]
=== END ===

=== /lib/catalog_search_extension.rb SNIPPET ===
module CatalogSearchExtension
   include Radiant::Taggable

   attr_accessor :product_results

   [... SNIP ...]

   # Customized render method that also searches products
   def render
     @query_result = []
     @product_results = []
     @query = ""
     q = @request.parameters[:q]

     unless (@query = q.to_s.strip).blank?
       tokens = query.split.collect { |c| "%#{c.downcase}%"}

       pages = Page.find(:all, :include => [ :parts ],
           :conditions => [(["((LOWER(content) LIKE ?) OR (LOWER 
(title) LIKE ?))"] * tokens.size).join(" AND "),
                          *tokens.collect { |token| [token] *  
2 }.flatten])

       products = CatalogProduct.find(:all,
                                      :conditions => [(["((LOWER 
(description) LIKE ?) OR (LOWER(title) LIKE ?))"] * tokens.size).join 
(" AND "),
                                                     *tokens.collect  
{ |token| [token] * 2 }.flatten])

       @query_result = pages.delete_if { |p| !p.published? }
       @product_results = products
     end

     lazy_initialize_parser_and_context

     if layout
       parse_object(layout)
     else
       render_page_part(:body)
     end
   end
end
=== END ===



James Thompson
IT Director & Web Programmer
Stewart & Associates, Inc.
550 West Kentucky Street
Louisville, KY 40203
(502) 583.5502
[EMAIL PROTECTED]
http://www.stewartaa.com/


_______________________________________________
Radiant mailing list
Post:   Radiant@lists.radiantcms.org
Search: http://radiantcms.org/mailing-list/search/
Site:   http://lists.radiantcms.org/mailman/listinfo/radiant

Reply via email to