How can I add labels dynamically based on {text-data} etc?
I would like to use values entered using macros like {text-data} to dynamically add as labels, alternatively be able to dynamically populate the options in the {label-options} macro. Is this possible somehow? Also, the same goes for using these values in other macros, like {contentbylabel}. I saw another post indicating the syntax %data:foo%, whick led me to think I might use syntax like {add-label:%data:foo%} or {contentbylabel:labels=%data:foo%}. I tried it but it didn't work. The post indicated that it was a version issue with the scaffolding macro. Can somebody confirm the above? In that case I'll have our sysadmin check our scaffolding version and have him update to latest version. Our Confluence is at version 2.10.2
/Martin
/Martin
1
person has this question
I have this question, too!
Tell me when someone answers.
The more people who ask this question, the more it gets noticed.
The more people who ask this question, the more it gets noticed.
-
Inappropriate?Hi Martin,
To use injection (which is the values using '%'), firstly the reporting macro used to wrap around your macro needs to have injection on, typically "injected=true". Secondly not all reporting macros allow injection - {report-info} doesn't, but {report-column} does, for example. What code exactly are you using?
I'm not sure if Scaffolding versions have anything to do with that, but upgrading to the latest version is usually a good idea anyway.
Cheers,
Jen -
Inappropriate?Hi Jennifer,
Thanks for your reply! I am actually looking for a way to use data entered into {text-data} fields in other macros (not report-macros), like {add-label} and {contentbylabel}. Alternatively, maybe there are {report}-macros that will serve as substitutes for my needs.
Specifically what I want to do is
1. Have something entered in {text-data} (or similar, like {list-data}) turn up as a label on the page
2. Have something entered in {text-data} (or similar) be added to the labels parameter of the {contentbylabel} macro (or a {report} substitute, if there is one, I'm not yet familiar with {report}-macros)
I’m glad someone is listening!
-
Inappropriate?Ah oops I was referring to the Reporting plugin to use the data from Scaffolding in other macros!
OK I'm not sure if this is the "best" way to do it, but when I need to do this I wrap the macro I want to inject into (in your case, say {contentbylabel}) with Reporting macros so that the values from the Scaffolding fields can be injected in. It's not very elegant and I usually need to use the {style} macro as well to make it look better as I use the {report-table} macros that allow injection.
A very quick example, assuming your {text-data} macro is on the same page as the report:
{report-table}
{local-reporter:data}
{local-reporter}
{report-column:injected=true}{contentbylabel:label=%data:foo%}{report-column}
{report-table}
No guarantees if that code works, you may need to tweak the injected key chain :) but this is roughly how I do it.
Hope that gives you something to work on.
Cheers,
Jen -
Inappropriate?Hi,
Well, it looks promising. Only slight drawback is I don't get it to work. When the injection into a macro didn't happen, I tried this very simple code:
{text-data:testlabel}<x>{text-data}
{report-table}
{local-reporter:data:testlabel}
{local-reporter}
{report-column:injected=true}%data:testlabel%{report-column}
{report-table}
The report rendered with the hardcoded string %data:testlabel%, not the value entered in {text-data}. Obviously, I'm missing something simple here?</x>
I’m hopefull
-
Inappropriate?This works - tested this one:
{text-data:testlabel}blah{text-data}
{report-table}
{content-reporter:data|space=@self}
{text-filter:data:testlabel|required=true}
{content-reporter}
{report-column:injected=true|title=Title}{contentbylabel:label=%data:testlabel%}{report-column}
{report-table} -
Inappropriate?Hi again,
It does indeed work, but slightly too well. It will now generate a report row for evrey value for data:testlabel in the whole space. My code will eventually end up in a live template, so I would really need a way to extract only the value for the current page, not all pages in the current space where the data:testlabel exist.
From the documentation, it seems obvious that I should be able to use the first construct you supplied (with local-reporter), but it doesn't work. Are you aware of any bugs in previous versions? I still don't know the version of our plugin, but it is supposedly the one being shipped with Confluence 2.10.2
...sorry to keep pestering you, and thanks for your prompt replies!
/Martin
I’m grateful
-
Inappropriate?No problem!
Use {local-reporter} instead of {content-reporter} then :)
{local-reporter:data}
{text-filter:data:testlabel|required=true}
{local-reporter}
For my example I had to search through the space.
Cheers, -
Inappropriate?OK, this is the exact code I'm trying out now:
{text-data:testlabel}blah{text-data}
{report-table}
{local-reporter:data}
{text-filter:data:testlabel|required=true}
{local-reporter}
{report-column:injected=true|title=Title}%data:testlabel%{report-column}
{report-table}
I skipped the {contentbylabel} bit until I can verify that the injection bit works. The above code only shows the first text-data field, but, alas, no report, and no errors...
The odd thing is, when I try this:
{text-data:testlabel}blah{text-data}
{report-table}
{local-reporter:data:testlabel}
{local-reporter}
{report-column:injected=true|title=Title}%data:testlabel%{report-column}
{report-table}
I get the report header and 1 empty row
Cheers,
/Martin -
Inappropriate?Hi again,
I've tried the above on your free hosted trial version with the latest versions of Scaffold and Reporting, but get the same result, and the documentation doesn't add much illuminiation either, unfortunately. Any further help much appreciated. It seems so close, and yet not there...
Cheers,
/Martin
I’m stumped
-
Inappropriate?(Solved)
I scouted this forum and picked up some ideas, and ended up with code like the below. When I stick it into a live template I achieve my goal of having other Confluence macros, like add-label and contentbylabel, being fed dynamic parameters based on local page data, like text-data or page title:
{text-data:mylabel}<...>{text-data}
{hidden-data}
{report-table}
{local-reporter:page:title}
{local-reporter}
{report-on:injected=true}Set up labels{add-label:%page:title%,cool}{report-on}
{report-table}
{hidden-data}
{report-table}
{local-reporter:data:mylabel}
{local-reporter}
{report-on:injected=true}h3. My pages
{contentbylabel:labels=%data:mylabel%}{report-on}
{report-table}
Thanks for all help!
/Martin
I’m extatic
Loading Profile...



EMPLOYEE