Hi all,
i set up several pages with "page properties macros" (which shall be hidden in the final approach) but want to display values from there in the current page via user macro.
Is that possible? I know the documentation says that "It is not possible to reference the metadata using the metadata key from within the page, or anywhere else on a Confluence page." but can we maybe succeed in an approach using REST or some other query against the confluence database?
If the page can render the information (given the macro is not "hidden") why can't we do this in another macro on the same page (admittedly effectively rebuilding the display part of the marco, but this time with the chance to format labels and values and to rearrange them)
Hope someone knows about that
Best regards
Olaf
PS: All the articles i have read so far aimed at displaying "normal" properties related to the page, not at displaying properties located inside the "page properties macro"
Community moderators have prevented the ability to post new answers.
Well, I have a thought. You could wrap your page properties macro within your user macro like this ...
image2015-12-8 9:28:30.png
In the user macro definition do something like this ...
## Developed by: Davin Studer ## Date created: 12/08/2015 ## @noparams #set($id = $action.dateFormatter.calendar.timeInMillis) <div id="ppContainer$id">$body</div>
The $id is so that you have a unique id in case you add it more than once to a page. Then you could use JavaScript in your user macro to get at the data like this ...
<script type="text/javascript"> AJS.toInit(function(){ // This would loop through all the key/value pair table rows. AJS.$('#ppContainer${id} .plugin-tabmeta-details table tr').each(function(index){ var key = AJS.$('th', this).text(); var value = AJS.$('td', this).text(); }); // This would target a specific key/value pair row. var row = AJS.$('#ppContainer${id} .plugin-tabmeta-details table th:contains("Key 2")').parent(); var key = AJS.$('th', row).text(); var value = AJS.$('td', row).text(); }); </script>
Here is the full thing.
## Developed by: Davin Studer ## Date created: 12/08/2015 ## @noparams #set($id = $action.dateFormatter.calendar.timeInMillis) <div id="ppContainer$id">$body</div> <script type="text/javascript"> AJS.toInit(function(){ // This would loop through all the key/value pair table rows. AJS.$('#ppContainer${id} .plugin-tabmeta-details table tr').each(function(index){ var key = AJS.$('th', this).text(); var value = AJS.$('td', this).text(); }); // This would target a specific key/value pair row. var row = AJS.$('#ppContainer${id} .plugin-tabmeta-details table th:contains("Key 2")').parent(); var key = AJS.$('th', row).text(); var value = AJS.$('td', row).text(); }); </script>
Lo! this works a treat. Thanks! But.... will it survive a re-implementation of how page properties are represented?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi all
thanks Gavin for providing such a nifty little thing to encapsulate that macro and provide accessors to the values with it...
Though we do not need that specific thing anymore since we switched to realizing our requirements with the metadata macros, I still consider that technique very inspiring!
Hoppe everyone watching my issue will find something useful!
Best regards
Olaf
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If you have Comala workflow installed you can use the "Get-Metadata" macro to display page properties or workflow metadata as well
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I am wanting to do this as well! It would be great to be able to fetch values from the data "inside" the Page Properties macro and display the e.g. through a user macro. Unfortunately I'm not a hardcore developer. Hope someone can figure this out soon.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'm looking for the exact same thing.
No-one has a clue how to achieve this?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Community moderators have prevented the ability to post new answers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.