Hi Chris,
Fat Free CRM supports a simple 'hooks' architecture that allows plugins to add things to views. I'm sorry it's not very well documented, but I'll try to give you an example. (As a side-note, I'd recommend renaming your plugin soon to something like 'crm_products', so I'll use crm_products as an example :) )
Here's a demo of how to extend the opportunities/show.html.haml template from a plugin:
1. Create a file in your plugin directory, at 'lib/crm_products/products_view_hooks.rb'
2. Open the file you just created, and add the following code:
class ProductViewHooks < FatFreeCRM::Callback::Base
insert_after :show_opportunity_bottom do |view, context|
view.render :partial => "/opportunities/quotes", :locals => {:f => context[:f]}
end
end
:show_opportunity_bottom is the hook that is available in opportunities/show.html.haml
3. In your plugin directory, edit 'lib/crm_products.rb', and add the following line:
require 'crm_products/products_view_hooks'
4. Finally, create a view partial in your plugin directory, at 'app/views/opportunities/quotes.html.haml'. Edit this file, and add your additional section.
Hope that helps!
Regards,
Nathan B
On Tue, Dec 13, 2011 at 10:42 AM, Chris Pelon
<CPe...@specialized-computers.com> wrote:
Hey Nathan,
As I continue development on my FFCRM plugin, I now would like to make some small changes to the core FFCRM views. For example, I have created a "quotes" model in my plugin that has a has_one relationship to an opportunity. I would like to add something
like = section(@opportunity, :quotes) ... to the opportunities/ show.html.haml file but I know that I should _not_ change this file so I can continue to be the current code base. How do I do this?
Hope this makes sense. If not let me know if it does not and I will try to be clearer.
Thanks Nathan!
-Chris