Make it clearer that Token module is required for token support

Created on 7 March 2024, 9 months ago
Updated 8 March 2024, 9 months ago

Problem/Motivation

Testing Simplenews 4 on a fresh Drupal 10 installation, assuming that tokens are available since "Newsletter tokens (caution)" are enabled. Tried to use tokens which were working in 3.x and see that they don't work ...

Steps to reproduce

  1. Install Simplenews and go to /admin/config/services/simplenews/settings/newsletter
  2. See that tokens can be enabled via "Newsletter tokens (caution)" and enable it
  3. Create a newsletter, send it (or view the node) and see that tokens don't work
  4. Install the Tokens module and see that tokens now work

Proposed resolution

I suggest to
a.) not allow to tick the "Newsletter tokens" box unless the Token module is active. It would be helpful to let people know in it's description that the Token module has to be active to make the checkbox available.

  1. Grey out the checkbox
  2. Add help text "Requires Token module" after the title

Now

Suggestion: Inactive checkbox with "Requires Token module" text

b.) Ideally require the Token module in simplenews.info in

dependencies:
  - drupal:node
  - drupal:field
  - drupal:options
  - drupal:views
  - drupal.token

Requiring the Token module shouldn't be much of an overhead -- on all of my production Token has been required by some module, that's why it was always available when I finally installed Simplenews on such a site.

xxx.) I like the new "Extra copy" option a lot. It should eventually made more obvious that one has to enter the recipient's email address above the Send extra newsletter button, as the text field reads exactly the same as for sending the preview.

Remaining tasks

📌 Task
Status

Active

Version

4.0

Component

Code

Created by

🇦🇹Austria nofue

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @nofue
  • 🇩🇰Denmark ressa Copenhagen

    Did you verify that these tokens exist? You should be able to see all available tokens under /admin/help/token if you have both Token and Help modules installed.

    I just tried creating a new field "First name" (field_first_name) and the token to use it was [simplenews-subscriber:user:field_first_name] which looks different from the structure of your tokens.

    I tried sending a newsletter, and the First name was included, via the token. The token also took effect, just viewing the node.

    If I enable "Customization > Newsletter tokens (caution)" under /admin/config/services/simplenews/settings/newsletter: I see this on the Simplenews edit form:

    Replacement patterns
    Browse available tokens.
    These tokens can be used in all text fields except subject and will be replaced on-screen and in the email.

    And if I click "Browse available tokens", a Token browser pops up.

  • 🇦🇹Austria nofue

    Thanks, @ressa. Seems the Token module was missing -- makes me wonder why simplenews doesn't require it in the first place?
    And even now, when everything works, the token reads [simplenews-subscriber:field_firstname] without the :user part your see.
    Oh, those Gremlins …

  • Status changed to Closed: works as designed 9 months ago
  • 🇩🇰Denmark ressa Copenhagen

    Thanks for conforming that it does work. But it seems to not be clear that Tokens are required ...

    How about we make this issue about fixing that problem? It is Open Source after all, and there's no one to improve it, but us -- the community.

    A first step could be that you added a few steps under "Steps to reproduce" and "Proposed resolution", and then we can all work on fixing it? Also, was the "Newsletter tokens" option shown as active, and could you enable it, even without Token module enabled? This does seem counter intuitive, if it's an active option ... The checkbox should probably be greyed out.

  • 🇦🇹Austria nofue

    @ressa, I very much appreciate your attitude. Glad if I can be of help with this -- let's see if I can still remember. I'm going to edit the initial post per your suggestion. Have a great day.

  • Status changed to Active 9 months ago
  • 🇩🇰Denmark ressa Copenhagen

    I am glad you agree, and thanks for updating the Issue Summary @nofue, I very much appreciate it. I'll also update the title and compress the "Problem" and other sections, to align it more with the new direction of the issue, to try to make it more immediately clear what the challenge is for new readers.

    I am not sure about making the Token module a requirement ... It is probably taking it too far, since not everyone will be using tokens.

    But I agree that making the Token requirement clearer on the /admin/config/services/simplenews/settings/newsletter page would be a big step in the right direction, and I have added a suggestion under your point "a." about that. Thanks!

  • 🇩🇰Denmark ressa Copenhagen
Production build 0.71.5 2024