Skip to content

Commit

Permalink
feat(filter): add black list, white list feature for Mailchimp
Browse files Browse the repository at this point in the history
  • Loading branch information
talha131 committed Jul 30, 2019
1 parent 8e6539b commit b96122d
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 1 deletion.
39 changes: 39 additions & 0 deletions documentation/content/Mailing List/mailchimp.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ comments: false
Slug: add-mailchimp
Category: Mailing List
authors: Talha Mansoor
mailchimp_filter: off
---

Elegant shows a form to subscribe to your newsletter, above the fold, in the right section of every article. Increased visibility is said to increase number of subscribers.
Expand All @@ -21,3 +22,41 @@ To customize user experience you can also define,
1. `EMAIL_SUBSCRIPTION_LABEL`,
1. `EMAIL_FIELD_PLACEHOLDER` and
1. `SUBSCRIBE_BUTTON_TITLE`

You can see Mailchimp Form in action in the sidebar. It's a working example. Enter your email address so that we can send you news of new Elegant releases in your inbox.

## Show Mailchimp Form by default

Just set `MAILCHIMP_FORM_ACTION` variable.

## Hide Mailchimp Form by default

Unset `MAILCHIMP_FORM_ACTION` variable.

This is the default setting.

## Hide Mailchimp Form by default. Show on Selected

1. Set `MAILCHIMP_FORM_ACTION`
1. Set `MAILCHIMP_FILTER` to `True`

This will hide Mailchimp form on all pages.

Now to show Mailchimp form on selected posts, in article metadata set

```yaml
mailchimp_filter: off
```
## Show Mailchimp Form by default. Hide on Selected
1. Set `MAILCHIMP_FORM_ACTION`
1. Remove `MAILCHIMP_FILTER` or set it to `False` which is its default value

This will hide Mailchimp form on all pages.

Now to hide Mailchimp form on selected posts, in article metadata set

```yaml
mailchimp_filter: on
```
6 changes: 6 additions & 0 deletions templates/_includes/_defaults.html
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@
{% set MAILCHIMP_FORM_ACTION = MAILCHIMP_FORM_ACTION %}
{% endif %}

{% if not MAILCHIMP_FILTER %}
{% set MAILCHIMP_FILTER = False %}
{% else %}
{% set MAILCHIMP_FILTER = MAILCHIMP_FILTER %}
{% endif %}

{% if not FREELISTS_NAME %} {% set FREELISTS_NAME = '' %}
{% else %}
{% set FREELISTS_NAME = FREELISTS_NAME %}
Expand Down
12 changes: 12 additions & 0 deletions templates/_includes/mailchimp.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
{% macro mailchimp(article) %}

{% from '_includes/_defaults.html' import MAILCHIMP_FORM_ACTION with context %}
{% from '_includes/_defaults.html' import MAILCHIMP_FILTER with context %}

{%if (not MAILCHIMP_FILTER or article.mailchimp_filter == "off") and article.mailchimp_filter != "on" %}

{% if MAILCHIMP_FORM_ACTION %}

{% from '_includes/_defaults.html' import EMAIL_SUBSCRIPTION_LABEL with context %}
{% from '_includes/_defaults.html' import EMAIL_FIELD_PLACEHOLDER with context %}
{% from '_includes/_defaults.html' import SUBSCRIBE_BUTTON_TITLE with context %}
Expand All @@ -12,4 +19,9 @@ <h4>{{ EMAIL_SUBSCRIPTION_LABEL }}</h4>
</form>
</div>
<!--End mc_embed_signup-->

{% endif %}

{% endif %}

{% endmacro %}
3 changes: 2 additions & 1 deletion templates/article.html
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ <h4>Tags</h4>
</ul>
{% endif %}
{% include '_includes/social_links.html' %}
{% include '_includes/mailchimp.html' %}
{% from '_includes/mailchimp.html' import mailchimp with context %}
{{ mailchimp(article) }}
{% from '_includes/freelists.html' import freelists with context %}
{{ freelists(article) }}
</div>
Expand Down

0 comments on commit b96122d

Please sign in to comment.