Adding functionality to a plugin


#1

What’s the best method of extending a plugin / engine?

In my case, I’m using the login_engine. I want the user to also
provide their address and phone number.

Would I just directly extend the plugin code? I wouldn’t do it by
putting my code right in vendor/plugins/login_engine, right?

Joe


#2

Joe Van D. wrote:

In my case, I’m using the login_engine. I want the user to also
provide their address and phone number.

Would I just directly extend the plugin code? I wouldn’t do it by
putting my code right in vendor/plugins/login_engine, right?

Is is just for this app or do you plan to use this extension on multiple
apps and need it as a plugin itself. If is just for this app and you are
using a engine (which you seem to be doing) then I believe you can
simply overlay your custom views in your app/ folder and it will take
precedence over the views in the engine. If you want to add your own
custom actions you can create a controller in your app directory and it
will be mixed into the controller in the engine allowing you to override
and add actions.

Eric


#3

On 11/23/05, Eric A. removed_email_address@domain.invalid wrote:

simply overlay your custom views in your app/ folder and it will take
precedence over the views in the engine. If you want to add your own
custom actions you can create a controller in your app directory and it
will be mixed into the controller in the engine allowing you to override
and add actions.

If I want to add a phone number and address to the login_engine, then
I’m going to need to modify the schema and possibly the model.


#4

joevandyk wrote:

On 11/23/05, Eric A. removed_email_address@domain.invalid wrote:

simply overlay your custom views in your app/ folder and it will take
precedence over the views in the engine. If you want to add your own
custom actions you can create a controller in your app directory and it
will be mixed into the controller in the engine allowing you to override
and add actions.

If I want to add a phone number and address to the login_engine, then
I’m going to need to modify the schema and possibly the model.

With the Login Engine, you can create your own user model as normal and
it will work just fine as long as you include the authenticated user
module (with ‘include LoginEngine::AuthenticatedUser’).


#5

In your case, you’ll probably want to:

  1. copy then adapt the schema (the latest versions of Engines support
    migrations that you can use to avoid the ‘copy’ part there - just add
    your changes as migrations in your own application/db/migrate folder)

  2. Create your own /app/models/user.rb file, remember to include
    LoginEngine::AuthenticatedUser, and then add any other validation &
    methods that will support your extra fields. If you don’t need any
    validation or any of that jazz, you won’t need to create your own
    model, since ActiveRecord will quite happily handle the extra fields
    for you.

  3. Copy & adapt any views or controller methods that will need to know
    about these extra editable fields. This will probably be the show/edit
    views, and the update code in the controller.

  • james