{hidden-data}
Plugin: Scaffolding Plugin
Hides its contents when the page is being viewed, but allows it to be modified when editing.
Usage
Parameters
| Name |
Required |
Default |
Description |
| whenEmpty | | | If present, will check if the named field is empty. If so, the contents will be hidden. |
| whenNotEmpty | | | If present, will check if the named field is not empty. If so, the contents will be hidden. |
| whenNoRows | | | If present, will check if the named table or repeating section has no rows. If so, the contents will be hidden. |
| whenHasRows | | | If present, will check if the named table or repeating section has rows. If so, the contents will be hidden. |
Examples
Empty content
This section hides itself if the text it contains is empty.
Recipes
Hi,
I've a dynamic table with
{table-data:xxx}Thanx
Robert
Selectively hiding columns is not possible at present. If you'd like to see such a feature in the future, please create a feature request.
I've noticed that his macro hides it's contents, but the macros within are still executed. Is there a way to prevent execution?
For example, within a {hidden-data} macro, I use a lot of {render-and-replace}, {report-on} and {user-options} for things like populating selection drop down values. Since I have dozens of these on a page, I'd like to prevent that code from executing, except when the page is in edit mode. Any suggestions?
Yes, this is deliberate. This allows you to have values which you can refer to elsewhere, but don't show up on the actual page in view mode.
If you want to prevent markup from executing, I'd suggest the show-if/hide-if macros, which do not render their contents if not displayed. Try {show-if:action=edit} to achieve the effect you're after.
Hi everybody,
Does someone know if the use of several parameters in this marco works? If yes, is it an "OR" or "AND"?
Example:
{hidden-data:whenNoEmpty=VDescTestFonc|whenEmpty=VNoTest1}bla bla bla{hidden-data}I would like to hide the text "bla bla bla" if the field VDescTestFonc is not empty or if the field VNoTest1 is empty...
But I have the feeling that it does not work when I test :'(
Is it normal?
Thanks a lot,
Stephane
It's a single value currently. Feel free to make a feature request. I'm not exactly sure how it would work, but it would definitely be handy to have a few extra options.
Hello,
Thanks for the feedback !
I have just posted a feature request here SCAFF-276. Make sure to vote
cheers
I've been trying to use this macro but the whenNotEmpty option does not seem to be working.
For instance, I have the following:
{text-data:Test}{text-data} {hidden-data:whenNotEmpty=Test} There is no text data {hidden-data} {get-data:Test}But this always shows the 'There is no text data' line when I save the page, even if I put data into the text-data spot. I noticed in a comment above someone had 'whenNoEmpty' so I tried that but that didn't seem to work either ( it just always hides it, which I assume is the default when the parameter is invalid ). I also just noticed that 'whenNotEmpty' is not in the actual usage statement, but all the other 3 items are.
Am I doing something wrong or has this just not been implemented yet?
Hidden data is kind of counter-intuitive in some ways... I think what you want here is:
{text-data:Test}{text-data} {hidden-data:whenEmpty=Test} There is no text data {hidden-data} {get-data:Test}Think of it as reading out 'This is hidden data when Test is empty.'
Also, hidden data will always display in edit mode regardless.
Updated by Steve Hajducko
Nov 26, 2008 13:39
Ah, well let me put the actual use case, rather than my test and it might make more sense. In my test case, what I meant was no matter if I had data in 'Test' or not, the hidden-data section was *always* showing.
Here's my actual page.
{hidden-data:whenEmpty=RDP Host} The RDP host for this tier is {text-data:RDP Host}. {hidden-data} {hidden-data:whenNotEmpty=RDP Host} There are no terminal services for this tier {hidden-data}If I'm reading this right, then when I put data into the RDP host text-data field, it will display the 'The RDP host for this tier is whatever.hostname' and if I leave it blank, I should just see 'There is no RDP host for this tier'.
If I fill in the data in the the 'RDP Host' text data, I get this -
The RDP host for this tier is hostname.example.com
There are no terminal services for this tier
And if I leave it blank, I get this -
There are no terminal services for this tier
Does that make sense? All these hide if empty, hide if not empty things confuse me sometimes and I get things mixed up.
Also, would it be viable to implement something like an 'else' statement for these type of clauses?
{hidden-data:whenEmpty=RDP Host} The RDP host for this tier is {text-data:RDP Host} {hidden-data:else} There are no terminal services for this tier. {hidden-data}If it's displaying both messages (outside of the edit screen), then there is probably a bug somewhere. Probably worth a bug report.
Unfortunately, implementing an 'else' is tricky. A new 'sub' macro would have to be created. Not impossible, but hasn't been a high enough priority to actually implement. If you'd like to see it, go ahead and create a feature request - we'll see if it can fit in the schedule.
Updated by Nathan Palmer
Jan 05, 2009 16:11
Is there a way to have it test for the value of a text-data or list-data? I'd like to hide/unhide based on a list-option that is selected. Something maybe like this.
{list-data:SiteType}{list-option}Ftp{list-option}{list-option}Web{list-option}{list-data} {hidden-data:whenFieldData=true|SiteType=Ftp} h2. Ftp Ftp information {hidden-data} {hidden-data:whenFieldData=true|SiteType=Web} h2. Web Web information {hidden-data}Is there any problem with whenNotEmpty? I am attempting to use it like this (in substitute for an else) and its always showing both values.
| *Encrypt using these keys*: | {hidden-data:whenEmpty=EncryptUploadKeys}{get-data:name=EncryptUploadKeys}{hidden-data}{hidden-data:whenNotEmpty=EncryptUploadKeys}No encryption{hidden-data} |