# Topic entrance like plugin for tags

**URL:** https://meta.discourse.org/t/topic-entrance-like-plugin-for-tags/173070
**Category:** Development
**Created:** [December 12, 2020, 7:22am UTC](https://meta.discourse.org/t/topic-entrance-like-plugin-for-tags/173070 "2020-12-12T07:22:16Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Eiji](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eiji/32/468368_2.png) [@Eiji](https://meta.discourse.org/u/Eiji)
#### Post date: [December 12, 2020, 7:22am UTC](https://meta.discourse.org/t/topic-entrance-like-plugin-for-tags/173070/1 "2020-12-12T07:22:16Z")

</div>

Hi, I’m working on my first `Discourse` plugin.

### The idea

We want to alter the tag links behaviour slightly, where, when a tag is clicked anywhere in Discourse, instead of going directly to it, it shows two options; the normal tag url ([forum.com/tag/tag-name](http://forum.com/tag/tag-name)) or a related (external) page of our choice ([something.site.com/some-name](http://something.site.com/some-name)). This option would only show for that are in the list.

The list will be in the form of a Ruby array of hashes (or JSON) and this can either be added directly to the plug-in, or be made available at a URL. (The former seems like it will be more resource-friendly - we can just update the list and rebuild the plugin when it updates, as the updates won’t be that often.)

```ruby
# Ruby array of hashes
array = [
  {forum_tag: "discourse", external_slug: "discourse"},
  {forum_tag: "dc", external_slug: "discourse"},
  {forum_tag: "xenforo", external_slug: "xenforo"},
  {forum_tag: "xf", external_slug: "xenforo"}
]

# OR

array.to_json
=> "[{\"forum_tag\":\"discourse\",\"external_slug\":\"discourse\"},{\"forum_tag\":\"dc\",\"external_slug\":\"discourse\"},{\"forum_tag\":\"xenforo\",\"external_slug\":\"xenforo\"},{\"forum_tag\":\"xf\",\"external_slug\":\"xenforo\"}]"

```

We basically want the option to display like when you click on a `replies` number on the main forum page:

 ![obraz](https://global.discourse-cdn.com/meta/original/3X/5/c/5cefc8145e628cf59402b1974b65ab8935893368.png)

### My thoughts

I found 2 methods in `Discourse` API related to tags:

1. `addTagsHtmlCallback` - In this case I would need to set `topic.tags` to empty array right after assigning its value to other variable. In that way I would prevent rendering `tags` and can write my custom code.

2. `replaceTagRenderer` - The second one allows me to change `tag` render which does not look so hacky as 1st method.

However please look that in both cases I need to return `raw` string. From what I found I can’t write and compile `Ember` template by hand. Obviously I can just render custom links and write a simple function with `jQuery` putting it to root of `app/assets/javascripts`, but that’s way different solution comparing to `Discourse` code.

Am I on the right track? Any/all help will be very much appreciated.

---

<div class="post-metadata">

### Author: ![Eiji](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eiji/32/468368_2.png) [@Eiji](https://meta.discourse.org/u/Eiji)
#### Post date: [December 15, 2020, 11:30pm UTC](https://meta.discourse.org/t/topic-entrance-like-plugin-for-tags/173070/2 "2020-12-15T23:30:34Z")

</div>

For anyone interested I’m happy to announce a first release of my plugin!

> **[Plugins / Discourse / Tag Link Popup · GitLab](https://gitlab.com/eiji-plugins/discourse/tag-link-popup)**
>
> Change a standard tag link to popup with standard and external links.

Looking forward for your feedback!

---

<div class="post-metadata">

### Author: ![Eiji](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eiji/32/468368_2.png) [@Eiji](https://meta.discourse.org/u/Eiji)
#### Post date: [December 18, 2020, 5:25am UTC](https://meta.discourse.org/t/topic-entrance-like-plugin-for-tags/173070/3 "2020-12-18T05:25:43Z")

</div>

For everyone interested I recommend to check the latest changes especially:

> **[Added import plugin page (5e827c01) · Commits · Plugins / Discourse / Tag...](https://gitlab.com/eiji-plugins/discourse/tag-link-popup/-/commit/5e827c017cffcf3a40024cb7d475e4d6c2ac01cc)**
>
> Added support for importing CSV, JSON and raw TEXT for bulk update Added custom parsers and integrated importing with existing validator Full i18n support Fixed found issues

Good … day (?) for everyone!

😈

---

<div class="post-metadata">

### Author: ![AstonJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/astonj/32/215041_2.png) [@AstonJ](https://meta.discourse.org/u/AstonJ)
#### Post date: [January 6, 2021, 3:29pm UTC](https://meta.discourse.org/t/topic-entrance-like-plugin-for-tags/173070/4 "2021-01-06T15:29:08Z")

</div>

Nice one @Eiji!

* * *

We’re hoping to use this plugin on Devtalk… for anyone experienced with Discourse plugins could you take a look to see if any improvements can be made please? We’d appreciate it 😊
