Re: FatFreeCRM

21 views
Skip to first unread message

Nathan Broadbent

unread,
Dec 14, 2011, 2:53:01 AM12/14/11
to Chris Pelon, fat-free-...@googlegroups.com
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


Steve Kenworthy

unread,
Dec 14, 2011, 9:44:58 PM12/14/11
to fat-free-...@googlegroups.com, Chris Pelon
The docs here might also help a bit more too.

https://github.com/fatfreecrm/fat_free_crm/wiki/Callback-hooks

steve

--
You received this message because you are subscribed to the Google Groups "Fat Free CRM Users" group.
To post to this group, send email to fat-free-...@googlegroups.com.
To unsubscribe from this group, send email to fat-free-crm-us...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/fat-free-crm-users?hl=en.

Reply all
Reply to author
Forward
0 new messages