From e781f3ed93a7f7dae5dcf3ee7ee677afc8377fb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Gait=C3=A1n?= Date: Tue, 26 Nov 2013 14:15:29 -0300 Subject: [PATCH] trigger custom --- analytical/templatetags/uservoice.py | 4 +++- docs/services/uservoice.rst | 24 ++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/analytical/templatetags/uservoice.py b/analytical/templatetags/uservoice.py index 540e488..0b71221 100644 --- a/analytical/templatetags/uservoice.py +++ b/analytical/templatetags/uservoice.py @@ -61,7 +61,9 @@ class UserVoiceNode(Node): options = {} options.update(getattr(settings, 'USERVOICE_WIDGET_OPTIONS', {})) options.update(context.get('uservoice_widget_options', {})) - trigger = getattr(settings, 'USERVOICE_ADD_TRIGGER', True) + + trigger = context.get('uservoice_add_trigger', + getattr(settings, 'USERVOICE_ADD_TRIGGER', True)) html = TRACKING_CODE % {'widget_key': widget_key, 'options': simplejson.dumps(options), diff --git a/docs/services/uservoice.rst b/docs/services/uservoice.rst index 6a9e089..da69149 100644 --- a/docs/services/uservoice.rst +++ b/docs/services/uservoice.rst @@ -129,6 +129,30 @@ with ``uservoice_widget_key``: These variable passed in the context overrides the default widget configuration. + +.. _uservoice-link: + +Using a custom link +------------------- + +Instead of showing the default feedback icon or tab, you can make the UserVoice +widget launch when a visitor clicks a link or when some other event +occurs. As the `documentation describe `_, simply add the ``data-uv-trigger`` HTML attribute to the element. For example:: + + Contact us + + +In order to hidden the default trigger, you should disable it putting +``uservoice_add_trigger`` to ``False``. + + context = RequestContext({'uservoice_add_trigger': False}) + return your_template_with_custom_uservoice_link.render(context) + +If you want to disable the automatic trigger globally, set in :file:`settings.py`:: + + USERVOICE_ADD_TRIGGER = False + + Setting the widget key in a context processor .............................................