Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

add ability to subclass the plugin #16

Merged
merged 1 commit into from Sep 9, 2011

Conversation

Projects
None yet
4 participants

dsh2dsh commented Aug 21, 2011

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.

@dsh2dsh dsh2dsh Add ability to subclass the plugin.
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.
8ab1532

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

@maccesch maccesch added a commit that referenced this pull request Sep 9, 2011

@maccesch maccesch Merge pull request #16 from dsh2dsh/master
add ability to subclass the plugin
49ac8c7

@maccesch maccesch merged commit 49ac8c7 into maccesch:master Sep 9, 2011

Owner

maccesch commented Sep 9, 2011

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

Sweet, thanks.

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 Sep 12, 2011

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.

oooh.. ok

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

Owner

maccesch commented Sep 12, 2011

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

Owner

maccesch commented Sep 12, 2011

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.

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.

Owner

maccesch commented Sep 13, 2011

Great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment