How to define a link that includes the Base URL of the current instance?

Normand Brousseau November 6, 2013

I wonder how to define a relative URL which would trigger a Confluence action within the current instance.

An example:

  • if I have the two following Base URLs:
    • for our PROD instance = [https://www.ourplace.com/confluence]
    • for our DEV instance = [https://www.ourplace.com/confluence-dev]
  • I would like the link to display the user's personal labels ("my:")
  • the relative link would be something like: users/viewmylabels.action
  • the output would depend on the instance:
    • in PROD = [https://www.ourplace.com/confluence/users/viewmylabels.action]
    • in DEV = [https://www.ourplace.com/confluence-dev/users/viewmylabels.action]

Of course, I could also apply the same recipe to many administrative actions within documented procedures.

While experimenting, I've found the following syntax:

<a href="../../users/viewmylabels.action">My labels</a>

However, it will work only when there are no international chars in the page title.

When international chars are found in the page title, the URL used for display resembles the following:

https://our_base_url/confluence/page/viewpage.action?pageId=32802766

Therefore, the Base URL is only "one relative level back", and the syntax must be changed to this:

<a href="../users/viewmylabels.action">My labels</a>

Is there a "Base URL" syntax that works regardless of the page title?

Thanks,
Normand

2 answers

1 accepted

1 vote
Answer accepted
Bruna Griebeler
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.
November 17, 2013

Hi Normand,

I believe Confluence by default will not allow the relative link to be placed on the page, unless you create the link using html code.

However to use html code on a page, you must enable the module html macro on the add-ons page: https://confluence.atlassian.com/display/DOC/Enabling+HTML+macros

Hope it helps!

Normand Brousseau November 18, 2013

Hi Bruna, Wie get's?

YES, your answer is very useful. Would you allow me to take it one step further?

I've activated the HTML macro in our TEST instance, and I want to include a link to display all "personal" (my:) labels created by the current user in the current instance.

Let's say the TEST instance Base URL is [https://www.ourplace.com/confluence-TEST] and the PROD instance Base URL is [https://www.ourplace.com/confluence]. I want the link to point to the user's own {{my:labels}} listing of the confluence-TEST instance if he's browsing there, but of the confluence (PROD) instance if he's in PROD. (I refresh our TEST instance just by reloading the PROD data, so the same link will be used.)

So far I've tried a syntax such as the following:

{html}
<a href="/users/viewmylabels.action">Click here</a> to see <b>your own</b> labels.
{html}

But the resulting link I'm getting does NOT include the instance name, i.e. "confluence-TEST" or "confluence", so I don't have the FULL Base URL.

Do you know what syntax should be used to yield the link, prefixed with the COMPLETE Base URL (i.e. $BASEURL/users/viewmylabels.action)?

Thanks!

Normand Brousseau November 19, 2013

And... another step further?

I've found the following syntax:

<a href="../../users/viewmylabels.action">My labels</a>

However, it will work only when there are no international chars in the page title.

When international chars are found in the page title, the URL used for display resembles the following:

https://our_base_url/confluence/pages/viewpage.action?pageId=32802766

Therefore, the Base URL is only "one relative level back", and the syntax must be changed to this:

<a href="../users/viewmylabels.action">My labels</a>

Is there a "Base URL" syntax that works regardless of the page title?

Normand Brousseau December 3, 2013

Sorry about the delay, I'm not too familiar with Atlassian Answers and karma management, so I'm not sure I'm treating this one properly...

I'm going to accept Bruna's answer (hope she gets her karma points!), which helped me a great deal forward (with the html macro) -- however, I still have no answer to my last question concerning the "relative link" topic.

Thanks anyway.

Normand

0 votes
Normand Brousseau November 24, 2013

I'm sorry I had to repeat my comment into the initial text, but my question has now slightly changed since I've been experimenting in parallel.

I still appreciate Bruna's previous answer (which was completely useful), but my solution is still incomplete.

Or maybe I don't understand how Atlassian Answers works -- maybe there's no good karma for completing an answer?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events