It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How can i extract automatically the name of the page i'm currently at?

le tu Aug 14, 2017

I have a certain line of code which I've defined to appear in any of my space's pages.

This line of code calls a certain script that needs to take as a parameter the page's name, but I don't know how to automatically extract the page's name...

 

maybe there's a certain code-word for this or another solution you could think of?

 

For example:

If my line of code is: 

http://sde-cgi....&tag={{PAGENAME}}....

 

I want PAGENAME to be automatically replaced with the name of the page.

 

Thanks,

-Le

 

1 answer

1 accepted

1 vote
Answer accepted
Stephen Deutsch Aug 14, 2017 • edited

Well, there's two ways you could do this:
1. Generate the link on the backend in a user macro. It would look something like this:

## @noparams
<a href="http://sde-cgi....&tag=$content.title" target="_blank">name of link</a>

2. Generate the link on the front-end with some Javascript. If you have the HTML macro activated, then you could do something like this:

<div id="tag-link"></div>
<script>
$("#tag-link").html('<a href="http://sde-cgi....&tag=' + AJS.params.pageTitle + '" target="_blank">name of link</a>');
</script>

the target="_blank" is there to make the link open in a new tab. If you don't care about that, you can just remove that part.

le tu Aug 14, 2017

interesting, I'm pretty new to this stuff so I couldn't understand the first option, and if you could guide me on where I can learn how to implement the second option it would be great...I know BASH/C++ so I think I'll be able to deal with JAVA if I'll have a good link to guide me...

Stephen Deutsch Aug 14, 2017

The first option is a user macro: https://confluence.atlassian.com/doc/writing-user-macros-4485.html

This is based on Apache Velocity, which Confluence uses in the background as a templating language. It's basically Java, and has access to many of the Java libraries.

The second option can be placed in the HTML macro, as long as it is activated:

https://confluence.atlassian.com/doc/html-macro-38273085.html

once you have activated the HTML macro, just insert it in a page and paste the text there, and it should work :)

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published in Confluence

6 Awesome Ways to Apply Trello, JIRA and Confluence to your Project

I attended  Atlassian Summit 2019  and learned a lot from the presenters, attendees and knowledgeable Atlassian product managers. The presentations I attended focused on applying Agile, pla...

2,411 views 11 28
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you