I'm trying to build a user macro that allows the user to add specific labels to a page using checkboxes. Is this posible because I can't seem to get it to work.
Even skipping the checkbox part, how do i get a user macro to add a label to a page?
I would use the label manager to create the checkbox list of label. Afterward on checkbox click i would call the original add label request via ajax. The following user macro code is a quick implement and is working for my Confluence 4. Maybe you can take this as a starter.
## @noparams <script type="text/javascript"> AJS.toInit(function ($) { //every label checkbox on the page jQuery(".custom_label_to_add").click(function(){ //call the add label ajax request jQuery.post(contextPath+"/json/addlabelactivity.action", {"entityIdString": "$content.id", "labelString": jQuery(this).val(), "atl_token": jQuery("#atlassian-token").attr("content") } ,function(){ alert("label added to page"); }); }); }); </script> #set($containerManagerClass=$action.class.forName('com.atlassian.spring.container.ContainerManager')) #set($getInstanceMethod=$containerManagerClass.getDeclaredMethod('getInstance',null)) #set($containerManager=$getInstanceMethod.invoke(null,null)) #set($containerContext=$containerManager.containerContext) #set($labelManager=$containerContext.getComponent('labelManager')) Popular Labels #foreach( $popularLabelResult in $labelManager.getMostPopularLabels() ) <br> <input type="checkbox" class="custom_label_to_add" value="$popularLabelResult.label.name"> $popularLabelResult.label.name #end
I was actually wanting to have the checkboxes(determine the $param's for the labels) inside the macro browser interface and not on the actual page. I'm wanting my users to use the macro browser, pick their labels, and then when they click insert it'll apply the labels to the page(or when they save the page). I already have the user macro reading the page labels and populating a div based on certain values found, but I can't seem to figure out how to add labels from the macro browser with a user macro.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
really helpful. Thanks!
That helped my as starting point for this:
(if you have any idea whats going wrong there...)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi folks,
this is a very honorable issue, which could help a lot for having reliable display in all pages working with the contentbylabel macro. I highly appreciate your efforts, but I'm not into coding by myself.
If you are about to offer a prototype or evaluated application, please consider the idea to distribute labels also downwards into all child pages. I can't see, why this is not available for a long time already.
From my point of view this is a very natural way how knowledge grows: First you distinguish step by step and then you want to mark all the stuff as belonging together somehow. In former times this was represented by folders with classical restrictions. Labels offer the way of having multidimensional structures. But it is too much work, to keep track of having them in really every single page. Some tools are definitely needed to facilitate the handling of documentation metadata.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.