Confluence User-Macro renders in preview but not in page

I have a usermaro which renders in the preview of the macro, but not after savig.

It has links to external scripts and stylesheets. Is that the problem? Or is there an other reason?

Once again: in the preview pane of the macro, i works perfectly fine!

2 answers

This widget could not be displayed.

Hello Andrew,

This is an interesting behavior. Was this tested in the latest confluence version? Do it works on other confluence instance or just this one? Is there any error appearing in the page after saving it?

Maybe you could provide an example of the custom macro code so we can perform some tests?

Cheers,

Rodrigo

Hi Rodrigo,

It's on Confluence 4.3

I haven't checked on other instances.

there were some minor errors, but nothing alarming.

the scripts for the example is scattered among internal servers, which is quite some work to assemble.

What happens is that we link to javascript from outside sources, and it seems that those work in the preview, but not "normally"

Sorry it's vague. I'll try to create a more simple example.

body {

margin: 20px 20px 20px 20px;

text-align: center;

font-size: 13px;

font-family: "Lucida Grande",Helvetica,Arial,Verdana,sans-serif;

}

#calendar {

width: 100%;

}

.fc-weekend {

color: grey;

}

.fc-weekend-column {

background-color: silver;

}

.greenEvent {

background-color: green !important;

color: grey;

}

.timeline {

position: absolute;

left: 59px;

border: none;

border-top: 1px solid red;

width: 100%;

margin: 0;

padding: 0;

z-index: 999;

}

.OOF {

background-color: silver;

color : black;

}

.concentratie {

background-color: #ABBDDC;

color : black !important;

}

.tentative {

color : white;

background-image: repeating-linear-gradient(135deg, transparent, transparent 10px, rgba(255,255,255,.2) 10px, rgba(255,255,255,.2) 20px);

}

.thuis {

background-color: #DDDDDD;

color : black;

}

$body

</style>

<p><div id='calupdate' style="text-align: left !important; color: silver;"></div></p>

<div id='calendar'></div>

<div id='contextMenuContainer' style='background-color:#f0f0f0;width:100px;height:100px;display:none;z-index:999;border-radius:5px;border:1px solid black;position:absolute;'></div>]]></ac:plain-text-body>

</ac:macro>

Maybe this helps?

It's in the user macro.

## Macro title: Exchange Agenda

## Macro has a body: Y

## Body processing: Rendered

## Output: HTML

##

## @paramurl:title=URL|type=string|required=true|desc=URL of API|default=.

## @paramuser:title=Gebruiker|type=string|required=true|desc=korte naam|default=NOUSER

#set( $user = $userAccessor.getUser($paramuser) )

#set( $user_src = "&g=" + $paramuser )

#set( $url = $paramurl )

<ac:macro ac:name="html">

<ac:parameter ac:name="atlassian-macro-output-type">BLOCK</ac:parameter>

<ac:plain-text-body><![CDATA[

<link href="$paramurl/fullcalendar/fullcalendar.css" rel="stylesheet" />

<link href="$paramurl/fullcalendar/fullcalendar.print.css" rel="stylesheet" media="print" />

<link href="$paramurl/jquery/jquery.qtip.min.css" rel="stylesheet" />

<script src="$paramurl/jquery/jquery-1.9.1.min.js"></script>

<script src="$paramurl/jquery/jquery.qtip.min.js"></script>

<script src="$paramurl/jquery/jquery-ui-1.10.2.custom.min.js"></script>

<script src="$paramurl/fullcalendar/fullcalendar.js"></script>

<script type="text/javascript" src="$paramurl/index2.php?js$user_src"></script>

<style>

This widget could not be displayed.

Hello Andrew,

i had the exact same Problem. The Javascript part of my Plugin was renderd in Preview Mode just fine but not once it was save to the Site.

There is a workaround for that issue.

In my .vm file i included

#if ($req.getRequestURI().contains("tinymce"))
         <script>update();</script>
    #elseif ($req.getRequestURI().contains("rendercontent.action"))
        <script>update();</script>
    #else
        <script>update();</script>
    #end

I just call my update function everytime the Macro URI changes from preview to saved state etc.

I hope this will help you

 

Greetings

Marco

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Sep 17, 2018 in Confluence

Why start from scratch? Introducing four new templates for Confluence Cloud

Hi my Community friends!  For those who don't know me, I'm a product marketer on the Confluence Cloud team - nice to meet you! For those of you who do, you know that I've been all up in your Co...

601 views 8 6
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you