Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to get the content ID of a page that includes the page

fgav
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
May 25, 2018

Hi there,

we are using Confluence Server with a plugin that allows us to send whole pages by E-Mail. With this URL I can run the service: 

/pages/mailpage/mailpage.action?pageId=$content.getIdAsString()

Works fine.

The problem starts when I want to include this URL as a link into the footer. Our footer is based on a page in CF and thus has its own Content ID. So everytime the link is called, it uses the CID of the footer and not the IDs of the pages the footer is included.

Is there any solution to this? Must be something like: check the page that includes the footer and use its id.

Thanks and greetings from Germany,

Franz

1 answer

1 accepted

1 vote
Answer accepted
David at David Simpson Apps
Atlassian Partner
May 25, 2018

Don't build the URL in the footer page but using Javascript on the actual page. Do something like this:

In Confluence Admin | Look and Feel | Custom HTML

Add to one of the fields:

<script>
AJS.toInit(function ($) {
if (AJS.params && AJS.params.pageId) {
$('#footerEmailLink').attr(
'href',
[ AJS.params.baseUrl, '/pages/mailpage/mailpage.action?pageId=', AJS.params.pageId ].join('')
);
}
});
</script>

This assumes that you currently have a link like this in the footer:

<a id="footerEmailLink" href="/pages/mailpage/mailpage.action?pageId=$content.getIdAsString()">Email page</a>

The existing href attribute will be replaced with the correct one.

fgav
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
May 29, 2018

Thank you so much, works perfect!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events