Add term name as token [name], used for example to search

Created on 11 March 2023, almost 2 years ago
Updated 27 July 2024, 5 months ago

Problem/Motivation

Great module, and it works well in Drupal 10 after the release of 3.x.

I am looking for a way to turn certain words into search links, and this module looks perfect.

So instead of linking to a term, I want to turn certain words into links which searches for that word, so that for example the word "nature" in the text links to this path: /search/nature.

Proposed resolution

Add an extra [name] token which is the term name, to be used used for example like this: /search/[name] in the "URL pattern" filter form field.

Remaining tasks

User interface changes

API changes

Data model changes

Feature request
Status

Needs work

Version

3.0

Component

Code

Created by

🇩🇰Denmark ressa Copenhagen

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

Merge Requests

Comments & Activities

  • Issue created by @ressa
  • Merge request !12Add support for using term name as token → (Open) created by ressa
  • 🇩🇰Denmark ressa Copenhagen
  • 🇩🇰Denmark ressa Copenhagen
  • 🇩🇰Denmark ressa Copenhagen

    I have now switched to using the module as intended, using terms ... but maybe this is still a useful feature?

  • Status changed to Needs review over 1 year ago
  • 🇩🇰Denmark ressa Copenhagen

    Actually, I now see that I could definitely use this feature, doing a search on a term, instead of linking to the term itself, so changing Status.

  • Open in Jenkins → Open on Drupal.org →
    Core: 10.1.x + Environment: PHP 8.1 & MariaDB 10.3.22
    last update over 1 year ago
    15 pass
  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 8.1 & MariaDB 10.3.22
    last update over 1 year ago
    15 pass
  • Status changed to Active over 1 year ago
  • 🇩🇰Denmark ressa Copenhagen

    Hmm, okay. I guess I need to update branch from 2.0.x to 3.x both here and on Gitlab.

    The "Run test/retest"-options have disappeared, after changing branch on Gitlab and rebasing, though ... Maybe I'll have to change Status to "Active" and back to "Needs review" to trigger testing against 3.0?

  • Status changed to Needs review over 1 year ago
  • 🇩🇰Denmark ressa Copenhagen

    Fingers crossed, tests will appear after this ...

  • 🇩🇰Denmark ressa Copenhagen

    Well, that didn't work ...

  • 🇩🇰Denmark ressa Copenhagen
  • 🇩🇰Denmark ressa Copenhagen

    Could it simply be because tests have not been enabled for 3.x branch?

  • 🇩🇰Denmark ressa Copenhagen

    Tests are not enabled.

  • Hello Ressa

    I'm following up from the pointer you left on this issue:
    https://www.drupal.org/project/glossify/issues/3351469 merge with Word Link Active

    I have installed your patch, and now I'm trying to figure out how to use Glossify.

    I activated the links and tooltips with taxonomy.

    Now I'm trying to figure out how to make it work for my purpose, for example, to link every occurrence of Google in a Text be linked to "https://google.com"

  • 🇩🇰Denmark ressa Copenhagen

    I tried enabling "Glossify: Tooltips with taxonomy" under /admin/config/content/formats/manage/basic_html and added https://example.org?search=[name] but get this error:

    InvalidArgumentException: The internal path component 'https://example.org' is invalid. Its path component must have a leading slash, e.g. internal:/foo. in Drupal\Core\Url::fromInternalUri() (line 416 of core/lib/Drupal/Core/Url.php).

    So it looks like only internal links work.

  • Yes, that is what I understood too.

    Fortunately, an older project I already had dismissed as being abandoned has released a D9 version some time last year (I missed it) and now there's a D10 version too:
    https://www.drupal.org/project/alinks

    I haven't tested it yet, but it looks promising

  • 🇩🇰Denmark ressa Copenhagen

    That other project looks stalled. I think a better approach would be to create an issue here, with a feature request to allow external links.

  • well, I already requested a merge with "word link" which is essentially a clone of alinks.

    alinks had a new dev release 7th September 2023.

  • Status changed to Needs work 7 months ago
  • 🇳🇿New Zealand klidifia

    The added lines are overwriting the variable declared in the previous line, so whilst this lets [name] be used, it means [id] cannot be used.

    Lets see if we can make them both work.

  • Status changed to Needs review 7 months ago
  • 🇳🇿New Zealand klidifia

    Have put both replacements in the same line, I can utilise both tokens OK.

  • Status changed to Needs work 5 months ago
  • 🇩🇪Germany Anybody Porta Westfalica

    @ressa thank you very much for the idea. I first thought, what you describe should better be a separate module or a submodule, but essentially your implementation just adds a further replacement.

    Now I think it would be even better to implement token support here to unify the functionality instead of adding further custom syntax / pseudo-tokens. What do you think about that?
    Could you do it?

  • 🇩🇰Denmark ressa Copenhagen

    Thanks for looking at this @Anybody and @klidifia for updating the patch. It's a great idea to add Token support for even more flexibility -- maybe @klidifia is able to add this feature?

Production build 0.71.5 2024