# "Hide" shortcode

**URL:** https://meta.discourse.org/t/hide-shortcode/25585
**Category:** Feature
**Created:** [February 23, 2015, 9:41pm UTC](https://meta.discourse.org/t/hide-shortcode/25585 "2015-02-23T21:41:08Z")
**Posts on this page:** 17
**Page:** 1

<div class="post-metadata">

### Author: ![Maestra\_Powers](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/maestra_powers/32/37362_2.png) [@Maestra\_Powers](https://meta.discourse.org/u/Maestra_Powers)
#### Post date: [February 23, 2015, 9:41pm UTC](https://meta.discourse.org/t/hide-shortcode/25585/1 "2015-02-23T21:41:08Z")

</div>

On my forum there’s a topic where guys make giveaways. And post authors decide themselves to who they want to giveaway their stuff. For this we have `[hide]text[/hide]` shortcode now (we’re on phpBB currently, gonna migrate soon) that hides text from guests by default. But also authors can specify how many posts users should have to see their hidden text. Like this: `[hide=200]text[/hide]`. It’s very handy for givaways and it would be cool to have this functional in Discourse. Otherwise I’ll have to write a JS crutch that will rip off hidden text after is was loaded on page and we all understand how easily this method can be hacked.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [February 23, 2015, 9:45pm UTC](https://meta.discourse.org/t/hide-shortcode/25585/2 "2015-02-23T21:45:36Z")

</div>

One sec, can you explain this a bit more, never heard of shortcodes before.

Can you describe this in a bit more detail and link to an example.

---

<div class="post-metadata">

### Author: ![elberet](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/elberet/32/122404_2.png) [@elberet](https://meta.discourse.org/u/elberet)
#### Post date: [February 23, 2015, 10:00pm UTC](https://meta.discourse.org/t/hide-shortcode/25585/3 "2015-02-23T22:00:14Z")

</div>

I think “shortcode” is just another term for BB-code.

And the feature he wants is a bbcode that emits

- if there is no parameter and the current user is registered and activated _or_ if there is a parameter and the current user has written at least this many posts: its contents,
- in all other cases: nothing.

Since Discourse caches the cooked post, a Discourse-specific version of this feature would either be significantly harder to write (replace tag content with clickable placeholder, fill in hidden content async on click with permission check on server), or would be laughably insecure (content present in cooked post, hidden via CSS, revealed by JS).

---

<div class="post-metadata">

### Author: ![Maestra\_Powers](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/maestra_powers/32/37362_2.png) [@Maestra\_Powers](https://meta.discourse.org/u/Maestra_Powers)
#### Post date: [February 23, 2015, 10:00pm UTC](https://meta.discourse.org/t/hide-shortcode/25585/4 "2015-02-23T22:00:33Z")

</div>

I’m not sure how you calling this. In Wordpress it’s shortcodes, in phpBB it’s BBcodes. Your [spoiler plugin](https://meta.discourse.org/t/discourse-spoiler-alert/12650) is a thing I’m talking about. [Here’s](https://www.phpbb.com/customise/db/mod/adaptive_hide_bbcodes/) plugin that we use, you can see examples there. It also can give access to text to a certain group but guys from my forum didn’t found this handy, so I’m not sure about benefit of this part.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [February 23, 2015, 11:35pm UTC](https://meta.discourse.org/t/hide-shortcode/25585/5 "2015-02-23T23:35:23Z")

</div>

Yes, @zogstrip is working on this using the HTML 5.1 features `<element>` and `<detail>`

[\<details\> HTML details disclosure element - HTML | MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/details)

```
[details=the summary]blablabal[/details]

```

will generate

```
<details>
<summary>the summary</summary>
blablabal
</details>

```

It almost works now, but the tags are only supported on Chrome and Safari..

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [February 23, 2015, 11:39pm UTC](https://meta.discourse.org/t/hide-shortcode/25585/6 "2015-02-23T23:39:33Z")

</div>

Reading through the plugin linked this is slightly different to spoiler, its about giving permission to certain groups to read parts of a post.

Technically building that is a nightmare wrapped in a nightmare.

---

<div class="post-metadata">

### Author: ![sigurdur](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sigurdur/32/122516_2.png) [@sigurdur](https://meta.discourse.org/u/sigurdur)
#### Post date: [February 23, 2015, 11:48pm UTC](https://meta.discourse.org/t/hide-shortcode/25585/7 "2015-02-23T23:48:17Z")

</div>

I figure the least nightmarish way to go would be to add a model and a controller that pull the hidden code through ember’s ajax somehow.

Writing this would truly be a nightmare, but it’s a worthy challenge as a plugin for anyone who isn’t busy for a couple of weeks or so..

.. not me though 😉

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [February 23, 2015, 11:57pm UTC](https://meta.discourse.org/t/hide-shortcode/25585/8 "2015-02-23T23:57:22Z")

</div>

> [@Maestra\_Powers](#):
>
> But also authors can specify how many posts users should have to see their hidden text

Oh yes we’re not doing that at all. That is not even on the radar. If that’s the case just have them post in a category that only allows trust level 1 or trust level 2 users or higher (or a group)..

But hidden text, with a summary, has been requested many times and we’re about to do it.

---

<div class="post-metadata">

### Author: ![chapel](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/chapel/32/122414_2.png) [@chapel](https://meta.discourse.org/u/chapel)
#### Post date: [February 24, 2015, 12:37am UTC](https://meta.discourse.org/t/hide-shortcode/25585/9 "2015-02-24T00:37:44Z")

</div>

> [@codinghorror](#):
>
> Oh yes we’re not doing that at all. That is not even on the radar. If that’s the case just have them post in a category that only allows trust level 1 or trust level 2 users or higher (or a group)..

That actually makes sense IMO. If the goal is to prevent guests or users under a certain level, having a category that they can only see is the way to go. It is a bit more cumbersome but serves the purpose and avoids disappointing guests who won’t even know they are missing out.

If need be, the posts with the code could be in the private category, and can be linked to from the public thread.

> [@codinghorror](#):
>
> It almost works now, but the tags are only supported on Chrome and Safari..

Is there a polyfill? Saw this but only glanced at it: [http://www.smashingmagazine.com/2014/11/28/complete-polyfill-html5-details-element/](http://www.smashingmagazine.com/2014/11/28/complete-polyfill-html5-details-element/)

---

<div class="post-metadata">

### Author: ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)
#### Post date: [February 24, 2015, 3:14am UTC](https://meta.discourse.org/t/hide-shortcode/25585/10 "2015-02-24T03:14:28Z")

</div>

I investigated the polyfills available, and they don’t work for our usecase (needing to re-apply it to a just-inserted section of dom). @zogstrip is writing a custom one, I believe?

---

<div class="post-metadata">

### Author: ![Maestra\_Powers](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/maestra_powers/32/37362_2.png) [@Maestra\_Powers](https://meta.discourse.org/u/Maestra_Powers)
#### Post date: [February 24, 2015, 7:24am UTC](https://meta.discourse.org/t/hide-shortcode/25585/11 "2015-02-24T07:24:04Z")

</div>

> [@codinghorror](#):
>
> It almost works now, but the tags are only supported on Chrome and Safari..

Why do you need HTML5 for this? [Here’s](http://rutracker.org/forum/viewtopic.php?t=4897027) an example of a spoiler working with HTML4 and JS. I made same one using jQuery for [my old forum](http://red-squadron.ru/forum/viewtopic.php?f=11&t=17).

> [@codinghorror](#):
>
> Oh yes we’re not doing that at all. That is not even on the radar. If that’s the case just have them post in a category that only allows trust level 1 or trust level 2 users or higher (or a group)..

We need this only for one topic. But I guess I’ll have to split it into 3-4 now and make a category for each one. Sounds obesity thought.

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [February 24, 2015, 9:44am UTC](https://meta.discourse.org/t/hide-shortcode/25585/12 "2015-02-24T09:44:14Z")

</div>

> [@Maestra\_Powers](#):
>
> Why do you need HTML5 for this?

Actually it’s HTML 5.1. And since this will be standard, we’d rather have a small polyfill in the meantime than implement a custom element 😉

> **Here's an example**
>
> of the plugin in use 😉

---

<div class="post-metadata">

### Author: ![chapel](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/chapel/32/122414_2.png) [@chapel](https://meta.discourse.org/u/chapel)
#### Post date: [February 24, 2015, 10:17am UTC](https://meta.discourse.org/t/hide-shortcode/25585/13 "2015-02-24T10:17:13Z")

</div>

Where’s the plugin so I can install it?

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [February 24, 2015, 10:17am UTC](https://meta.discourse.org/t/hide-shortcode/25585/14 "2015-02-24T10:17:50Z")

</div>

Sorry, I forgot to link to the topic 😄

[https://github.com/discourse/discourse-details](https://github.com/discourse/discourse-details)

---

<div class="post-metadata">

### Author: ![Maestra\_Powers](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/maestra_powers/32/37362_2.png) [@Maestra\_Powers](https://meta.discourse.org/u/Maestra_Powers)
#### Post date: [February 24, 2015, 10:25am UTC](https://meta.discourse.org/t/hide-shortcode/25585/15 "2015-02-24T10:25:10Z")

</div>

> [@zogstrip](#):
>
> since this will be standard

If this is not supported by FireFox and IE yet, then I think it’s better way to use JS for now. Considering that HTML 5.1 approach is not much easier than JS one.

---

<div class="post-metadata">

### Author: ![chapel](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/chapel/32/122414_2.png) [@chapel](https://meta.discourse.org/u/chapel)
#### Post date: [February 24, 2015, 10:29am UTC](https://meta.discourse.org/t/hide-shortcode/25585/16 "2015-02-24T10:29:26Z")

</div>

See post above you. Install that and you have what you want, it uses JS for browsers that don’t support it.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [March 11, 2015, 8:04am UTC](https://meta.discourse.org/t/hide-shortcode/25585/17 "2015-03-11T08:04:15Z")

</div>


