4

Is it possible to show and hide blocks of content in the trac wiki similar to the cloak macro of confluential?

Vitali
  • 313
  • 1
  • 9

4 Answers4

6

It's a few month old but I was wondering the same thing. Remy Blank answer put me on the right track, he was just missing an extra div.

{{{#!div
{{{#!html
<h3 class="foldable">Section title</h3>
}}}
{{{#!div
This is the section content.
}}}
}}}

If you look at the style sheet, it shows you which element gets hidden with the collapsed style.

.collapsed > div, .collapsed > table, .collapsed > ul, .collapsed > dl { display: none }

Remy's code was wrapping "This is the section content" inside a p markup, that's why it wasn't hidden.

Gregoo
  • 76
  • 1
  • 2
1

I'm super late to the party, but the FoldMacroProcessorMacro lets you do this without resorting to HTML.

Dang Khoa
  • 5,693
  • 8
  • 51
  • 80
1

If you just want to (temporarily) hide some content while keeping it in the page source, you can use the {{{#comment}}} wiki processor. As mentioned by bta, the content is still accessible by downloading the page source, so this is not a security measure.

If you want to collapse a section, and allow users to expand it by clicking, you can use the following trick (tested with 0.12):

{{{#!div class=""
{{{#!html
<h3 class="foldable">Section title</h3>
}}}
This is the section content.
}}}

This will show the section title with a small triangle on its left, and clicking the title will toggle the section between collapsed and expanded. The section will initially be collapsed.

Remy Blank
  • 4,236
  • 2
  • 23
  • 24
  • i'd like to have a section that a user my collapse and expand, but unfortunately the trick did not work for me. I got a section with a triangle, but it is expanded initially and clicking on it does not change anything. I run track 0.12b1 – Vitali Mar 29 '11 at 16:51
0

The current versions of Trac do not have permissions this fine-grained. User accounts can be granted wiki access, but it's an all-or-nothing setting. The raw wiki-format version of a wiki page can be downloaded in plain text using the links at the bottom of the wiki page, so a macro like this wouldn't really restrict content.

It's possible to write an add-on that blocks access to a particular wiki page based on user account name or permissions, but that's still page-level granularity and not block-level like the macro you mentioned.

bta
  • 43,959
  • 6
  • 69
  • 99