The {toggle-cloak} macro is used in conjunction with the cloak macro to show and hide blocks of content...
When pages become extremely large, or when there is information that might not always be required, you can use this macro in conjunction with the cloak macro to temporarily hide blocks of content. The user can show or hide cloaked blocks using on-screen navigation provided by this macro.
Usage
The {toggle-cloak} macro has the following parameters:
{toggle-cloak:id=i|exclusive=v} your content
Parameters
Parameter
Required
Default
Notes
id
The unique ID to assign to a cloak toggle. The cloak macro uses this ID to identify the blocks of content to be shown/hidden.
exclusive
false
By default the cloak-toggle will only affect those cloaked areas with the same ID, however by setting this parameter to true all other pieces of cloaked content at the same level will be hidden as the cloaked content with the matching ID is revealed.
Examples
Basic Cloak Toggling
At its most basic level you can toggle a single cloak
{toggle-cloak:id=MyCloakID}Click here to toggle the cloak
{cloak:id=MyCloakID}This content will be cloaked{cloak}
Results in:
Click here to toggle the cloak
This content will be cloaked
Cloak Toggling Multiple Content Blocks
You may many different content blocks on a single page, in this example they all work independently of one another, in later examples you will see how to force only one cloaked area to be visible at a time.
{toggle-cloak:id=CloakID1}Click here to toggle cloak CloakID1
{cloak:id=CloakID1}This content can be cloaked{cloak}
{toggle-cloak:id=CloakID2}Click here to toggle cloak CloakID2
{cloak:id=CloakID2}This content can be cloaked{cloak}
{toggle-cloak:id=CloakID3}Click here to toggle cloak CloakID3
{cloak:id=CloakID3}This content can be cloaked{cloak}
Results in:
Click here to toggle cloak CloakID1 This content can be cloaked
Click here to toggle cloak CloakID2 This content can be cloaked
Click here to toggle cloak CloakID3 This content can be cloaked
The toggles don't need to be next to the cloaks they control - you can put them anywhere, for example:
{toggle-cloak:id=CloakID1a}Click here to toggle cloak CloakID1a
{toggle-cloak:id=CloakID2a}Click here to toggle cloak CloakID2a
{toggle-cloak:id=CloakID3a}Click here to toggle cloak CloakID3a
Cloakable regions:
{cloak:id=CloakID1a}This is content cloaked with ID CloakID1a{cloak}
{cloak:id=CloakID2a}This is content cloaked with ID CloakID2a{cloak}
{cloak:id=CloakID3a}This is content cloaked with ID CloakID3a{cloak}
Which results in:
Click here to toggle cloak CloakID1a
Click here to toggle cloak CloakID2a
Click here to toggle cloak CloakID3a
Cloakable regions:
This is content cloaked with ID CloakID1a
This is content cloaked with ID CloakID2a
This is content cloaked with ID CloakID3a
Multiple Cloak Toggles
You may also have multiple cloak-toggle macros for a single cloaked area.
{toggle-cloak:id=CloakMany}Click here to toggle the cloaked area below
{cloak:id=CloakMany|visible=true}This content can be cloaked{cloak}
{toggle-cloak:id=CloakMany}Click here to toggle the cloaked area above
Results in:
Click here to toggle the cloaked area below
This content can be cloaked
Click here to toggle the cloaked area above
Controlling Other Cloaks
There may be times when you only wish to have a single cloaked area visible, so that as you reveal one area, the others hide themselves
{toggle-cloak:id=CloakExclusive1|exclusive=true}Click here to toggle the cloaked area 1
{cloak:id=CloakExclusive1|visible=true}This is cloaked area 1{cloak}
{toggle-cloak:id=CloakExclusive2|exclusive=true}Click here to toggle the cloaked area 2
{cloak:id=CloakExclusive2}This is cloaked area 2{cloak}
{toggle-cloak:id=CloakExclusive3|exclusive=true}Click here to toggle the cloaked area 3
{cloak:id=CloakExclusive3}This is cloaked area 3{cloak}
Results in:
Click here to toggle the cloaked area 1
This is cloaked area 1
Click here to toggle the cloaked area 2
This is cloaked area 2
Click here to toggle the cloaked area 3
This is cloaked area 3
Hints and Tips
Remember to include the composition-setup macro at the top of your content when using the cloak macro. You should also ensure that you have at least one toggle-cloak macro for each cloaked section of your content so that the user can display that content.
Hi Guys,
Can I link to specific toggles from other pages, I might have my list ...
Hi Guys,
Can I link to specific toggles from other pages, I might have my list on one page, and then want a specific cloak to appear according to my choice. A bit similar to using anchors.
I'd like to be able to run two SQL calls on a page. Can I use the toggle-cloak ...
I'd like to be able to run two SQL calls on a page. Can I use the toggle-cloak macro to only call the SQL once it has been 'uncloaked'? i.e. I don't want both SQL statements to execute when the page loads - only when the user clicks on the toggle.
Comments (4)
Jan 19, 2007
Anonymous says:
Hi Guys, Can I link to specific toggles from other pages, I might have my list ...Hi Guys,
Can I link to specific toggles from other pages, I might have my list on one page, and then want a specific cloak to appear according to my choice. A bit similar to using anchors.
May 09, 2008
Margo Kelly says:
Is there a way to make an expand all / collapse all button?Is there a way to make an expand all / collapse all button?
Oct 01, 2010
Sam Kenny says:
I'd like to be able to run two SQL calls on a page. Can I use the toggle-cloak ...I'd like to be able to run two SQL calls on a page. Can I use the toggle-cloak macro to only call the SQL once it has been 'uncloaked'? i.e. I don't want both SQL statements to execute when the page loads - only when the user clicks on the toggle.
Thanks very much,
Sam
Jul 08, 2011
David K says:
Hi, I have a problem with toggle-cloak macro which contains survey macro. I use...Hi, I have a problem with toggle-cloak macro which contains survey macro.
I use Confluence 3.5.5, Composition-plugin-2.3.5, Survey-macro-1.1.8.8.
Code:
{composition-setup}
{composition-setup}
{toggle-cloak:id=My Cloak} Rate it!
{cloak:id=My Cloak|visible=false}
{survey:choices=5 - Excellent, 4 - Good, 3 - Fair, 2 - Poor, 1 - Very Poor|changeableVotes=true|startBound=1}Reusablity benefit
Quality of the requirement coverage{survey}
{cloak}
Survay macro is used for feedback from users, so users can select some
opinion or rate some questions. This questionaire form takes too much place and
that's why I used toggle-cloak macro to give some user possibity to show or hide this hudge form.
It's clear that when I click on "Rate it!
" the content hides or shows. But the problem is, when a user click on s submit button
in the form (located in content of toggle-cloak macro, see above), the form is hidding immediatelly.
Could anyone to help me? Or give me some answer, or recommend me some forums or websites to resolve my problem?