[ckan-dev] Overriding helper functions?

Denis Zgonjanin deniszgonjanin at gmail.com
Fri Jan 30 19:25:49 UTC 2015


Hi Andrew,

You can certainly monkey patch the methods. Simply write your own and
overwrite that function from ckan.lib.helpers. I seem to remember doing
something like that here:

https://github.com/open-data/ckanext-wet-boew/blob/master/ckanext/wet_boew/plugins.py#L37

Of course, you should be careful as this approach is a hack by any measure.

On Wed, Jan 28, 2015 at 2:52 PM, Koebrick, Andrew (MNIT) <
andrew.koebrick at state.mn.us> wrote:

>  Is it possible to override a template helper function in an extension?
> I have a functional rewrite of the follow_button helper (it calls a new
> snippet when users are not logged in, prompting them to create an
> account).  I was hoping to just name it the same as the existing
> follow_button so that I would not have to rewrite the existing templates to
> point to the new function.  I see this warning in get_helpers:
>
>
> *# Template helper function names should begin with the name of the *
>
> *# extension they belong to, to avoid clashing with functions from *
> *# other extensions.*
>
> But is this just good form, or can I somehow have a helper with the same
> name as a stock helper, but have mine called instead.  I have tried, but I
> get errors when using the same name…  Any tricks to let me avoid rewriting
> templates?
>
>
>
>
>
> *Andrew Koebrick  | * MINNESOTA GEOSPATIAL INFORMATION OFFICE
>
> Web Coordinator / Systems administrator / Librarian
>
> MN.IT Services @ CENTRAL
>
> 651-201-2465 (w)  *|  * 651-296-6398 (f) *|*  andrew.koebrick at state.mn.us
>
> 658 Cedar St., Room 300, St. Paul, MN 55155, www.mngeo.state.mn.us
>
> *[image: cid:image002.jpg at 01CE61F8.52552AE0]* <http://www.mn.gov/oet>
>
> Information Technology for Minnesota Government   *|*   mn.gov/oet
> <http://www.mn.gov/oet>
>
>
>
>
>
> _______________________________________________
> ckan-dev mailing list
> ckan-dev at lists.okfn.org
> https://lists.okfn.org/mailman/listinfo/ckan-dev
> Unsubscribe: https://lists.okfn.org/mailman/options/ckan-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/ckan-dev/attachments/20150130/d61d63d2/attachment-0003.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.jpg
Type: image/jpeg
Size: 1624 bytes
Desc: not available
URL: <http://lists.okfn.org/pipermail/ckan-dev/attachments/20150130/d61d63d2/attachment-0003.jpg>


More information about the ckan-dev mailing list