Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Confluence: user macro to display excerpts

R Donato
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 9, 2015

Hello,

I've created a glossary where each page is a definition that is in an excerpt macro. I'd like to display these terms as pop-ups in documents. How do I create a user macro to do this? I know it can be done. Any suggestions?

Thanks much!

5 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

2 votes
Answer accepted
Alex Medved _ConfiForms_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 11, 2015

Quick prototype with user macro:

## Macro title: tooltipme
## Macro has a body: Y
## Body processing: Rendered
## Output: Selected output option
##
## Developed by: Vertuna LLC
## Date created: 11/01/2015
## This is an example macro
## @param Name:title=Tooltip name|type=string|required=true|desc=JS ID for your tooltip element
## @param Text:title=Link text|type=string|required=true|desc=Link text


<a id="${paramName}Link" href="#">$paramText</a>
<script type="text/javascript">
    AJS.$(document).ready(function() {
        AJS.$("#${paramName}Link").attr('original-title', AJS.$("#${paramName}").html());
        AJS.$("#${paramName}Link").tooltip({html:true});     
   });  
</script>
<div id="$paramName" style="display:none">
$body
<div>

Make sure "Rendered" option is selected as output.

And when you add this macro to the page put excerpt include macro as it's macro body.

Basically it can make tooltip if anything you give it as input.

You will need to alter the CSS styles a bit, as by default, the tooltips are rendered on a dark background and this is probably not what are you looking for.

 

Configuration on page

tooltip-config.png

View mode

tooltip.png

R Donato
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 12, 2015

Sash, thanks for the prototype. Unfortunately, I wasn't able to get it to work. I'm on version 5.4.2. Is your code compatible with that version? I created the macro per our instructions and selected rendered. Once created, I could only add the tooltip macro to the page when a "Tooltip name" and "Link Text" are entered. For "tooltip name" I added the name of the term I want defined. For "link text", I added the tiny link to the excerpt page to include. Once I did that, I added the "excerpt include" macro to the body of the tooptip and filled it out as usual. After saving the page, though, nothing happened. The link displayed, but nothing popped up. If you could please provide information and examples of what I should put in the "Tooltip name" and "Link Text" fields, that might help resolve the problem. I'm not even sure why those fields are necessary. How exactly did you get this macro to work? It would be a lifesaver if I could get it to function the way you discribe. I even like that the definition displays with a black background with white text. Kind regards, Rosemary

Alex Medved _ConfiForms_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 12, 2015

Just retried it with Confluence 5.4.2 and it works the way it should. See updated answer above with the screenshot attached

R Donato
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 13, 2015

Hmm, I wonder if it's a RefinedWiki issue. I'll have to play around with this because your solution is what I want. I'll select yours as the answer even though I haven't gotten it to work yet. Thanks so much for your help! Much appreciated. :)

R Donato
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 13, 2015

Sash, I tried it again and it worked! I realized from looking at your screenshot that all I had to do was put in the name of the page that contains the excerpt and not the actual tiny link. Your image cleared everything up. Thanks again for the macro. You have serious made my day. :)

R Donato
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 15, 2015

Hey, Sash, I can only have one tooltip that works on a page. For example, if I have 4 different terms on a page that are pulling excerpts to display in Tooltipme, only the first one works. I even copied the first one that works and pasted it at the bottom of the page. When I saved the page, the first tool tip worked (tooltipme). But the copy at the bottom of the page didn't work. Do you know what I need to add to the macro to have unlimited tooltips display on a page?

Alex Medved _ConfiForms_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 15, 2015

Give different names ("Name:" parameter)

R Donato
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 16, 2015

That did the trick. Thanks again.

Evgeny Victorov January 19, 2016

Just the ending <div> should have the opening slash: </div>, otherwise is brakes.

 

Evgeny Victorov January 19, 2016

@Sash [ConfiForms], one more question - the tooltip is limited by width, and I can't stretch it to make it wider - some content may have limited. How could it be widened?

0 votes
Steven F Behnke
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 7, 2015

I lifted some code from other Atlassian Answers, this is my frankenstine. You could use .renderConfluenceMacro("{excerpt-include:$parampage|nopanel=true}") instead of course as well. 

I can create an "index" of pages, and lift them as tool tips.

The issue I've run into so far is that " " " and " ' " can break this.

## Installed by: 
## Date Installed: 
## @param page:title=Page|type=confluence-content|required=true|desc=Find page to include content from.
#foreach ($p in $parampage.split(":"))
    #set ($pagename = $p)
#end
 
&lt;style&gt;
.tipsy-inner {
max-width: 400px !important;
text-align: left !important;
}
&lt;/style&gt;
 
&lt;script type="text/javascript"&gt;
AJS.$(document).ready(function(){
    AJS.$('.includetip').filter(function() {
        return AJS.$(this).offset().left &gt;= AJS.$(window).width() / 2;
        })
        .tooltip({ html:true, gravity: 'e' });
    AJS.$('.includetip').filter(function() {
        return AJS.$(this).offset().left &lt; AJS.$(window).width() / 2;
        })
        .tooltip({ html:true, gravity: 'w' });
});
&lt;/script&gt;
 
&lt;a class="includetip" style="text-decoration:none; border-bottom:1px solid;" title='$action.getHelper().renderConfluenceMacro("{include:$parampage}")'&gt;$pagename&lt;/a&gt;
0 votes
Justin Justin January 11, 2015

@R Donato,

Are you thinking of something like PopView here? (See example in-line in the linked page.)

https://www.appfusions.com/display/POPVW/Home

R Donato
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 12, 2015

Hi, Justin, thanks for providing the link. But it looks like the excerpt text has to be added to the macro. I want to avoid that since the pages are already created. We want to avoid having to copy and paste definitions in multiple places and/or macros. We just want to call the definition and have it display in a pop-up. I think for one-offs, this macro would be a good tool to use. Thanks for your suggestion.

Justin Justin January 12, 2015

Hi R ... honestly, wasn't sure since it'd been a while since I tried that. The content that was on the linked page was old and not updated when Confluence (which website is running on) and plugin was updated to 5.4.1. It is updated/fixed now. It does work how you are saying, I think, if understanding right. The example for "Sneeches - Abdominal Stars" page (title) just required inserting the macro (no wiki-markup) and selecting the page reference. It automatically pulled rest of the parameters, including the tooltip text (you do not need to put in an excerpt). You can edit the tooltip text, caption, tooltip width later also if you want. See the screenshot. You know, we would be open to improving this, so feedback is welcome. This was AppFusions' *very first* plugin in April 2010, so it's sorta historically novel to us. :)

R Donato
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 13, 2015

Thanks for the response and for all your suggestions! I'll play with the macro and send over some feedback. Anything to improve Confluence functionality is appreciated. cheers!

0 votes
R Donato
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 9, 2015

Hi Sash,

I didn't explain what I want very well. I want to create a user macro that displays an excerpt as a tool-tip for definitions from the glossary.

Unless I've misunderstood what you've written, your suggestion doesn't provide the pop-up functionality for individual terms that I can use in documents.

Thanks anyway though.

0 votes
Alex Medved _ConfiForms_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 9, 2015

It could be done without a user macro smile

You can create a page that has a excerpt that references excerpts from you glossary pages (like a master excerpt :-) )

And then can reference that page (with master excerpt) from your documents. Kind of excerpt of excerpts. Just tried in Confluence, and it works fine

Sounds like inception, but works smile

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events