maccesch / cmsplugin-contact

Extendable contact plugin for django-cms with spam protection and i18n
BSD 2-Clause "Simplified" License
71 stars 62 forks source link

add ability to subclass the plugin #16

Closed dsh2dsh closed 13 years ago

dsh2dsh commented 13 years ago

See examples/cmsplugin_custom_contact how to subclass cmsplugin_custom and add custom fields into it. You can override properties of subclassed ContactPlugin and use your own templates and classes.

mbaechtold commented 13 years ago

When is this going to be merged? It's quite common that the contact form has to be customized.

maccesch commented 13 years ago

I always wanted to do this, thank you very much!

mbaechtold commented 13 years ago

Sweet, thanks.

Lacrymology commented 13 years ago

Excuse me, I'm not understanding how to subclass this.

Do I need to remove this the original from the apps? Does creating cms_plugins.py and adding the dir to installed apps suffice? Will both types of plugin appear on the list?

because I'm having trouble with this, maybe I'm missing something silly. Thanks

dsh2dsh commented 13 years ago

You can remove the original from the apps. It doesn't matter. If you'll remove it, you will not use the original and will use only your extended plugin. But if you need it you can use both. Just give your plugin different name like here:

class BaseContactPlugin(ContactPlugin):
    name = _("Custom Contact Form")

Don't forget, you need your custom cms_plugins.py, a model, a form and I think a template. You can use cms_plugins.py from examples dir as a start point.

Lacrymology commented 13 years ago

oooh.. ok

I'm gonna try a hackier way to go about this, if it works, I'll post about it

maccesch commented 13 years ago

The example is a bit rough. I'm putting together a working example right now.

maccesch commented 13 years ago

Alright I just pushed the working example.

Please note, that it requires the original cmsplugin_contact in the INSTALLED_APPS because it uses the original admin templates.

Lacrymology commented 13 years ago

Ok. But i also spotted some mistakes in the templates (form.captcha_fiel instead of 'field', is what comes off the top of my head) so I might fork and send some fixes tomorrow.

maccesch commented 13 years ago

Great!