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

Are there page scoped variables/constants?

Tomasz Glinski February 16, 2016

I mean something that would help in such situation:

I have a page with links to some development environment apps, that looks like this:

GUI: 123.123.123.123:8080/gui

Admin: 123.123.123.123:9090/admin

sthOther: 123.123.123.123:9091/sthOther

sthOther2: 123.123.123.123:9092/sthOther2

 

And that is repeated many times for different environments, and the IPs sometimes change. So I would like to do sth lik this

$qaIP = 123.123.123.123

GUI: $qaIP:8080/gui

....

So that I change one place and when page is displayed, all addresses are correct and updated. Oviously should work also for links.

Is there such functionality?

 

1 answer

1 accepted

0 votes
Answer accepted
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 17, 2016

Sort of.  I use include, excerpt, multi-excerpt and user macros to do stuff like this:

  • Include lets you include a whole page as part of another one.  So you could have a page called gui, with just that string on it, and use "include: gui".  When the gui page is edited, anywhere referencing it will display the new values on next edit.
  • Excerpt does much the same, except that it lets you take part of a page, rather than the whole thing.
  • Multi-excerpt is an add-on which fixes the problem that the built-in excerpt can only extract one part of a page - if you have a single page with all your variables on it, then you'd need multi-excerpt to access them
  • User macros are a totally different approach - you can write simple macros that contain your variable and then very quickly reference them.  To change the data displayed, an admin edits the macro.  More suitable for things that don't change a lot, or need to be controlled only by admins
Tomasz Glinski February 17, 2016

Well, I don't think that's the solution unless excerpts take params (they don't)... Own macros looks like the only solution, but muuch to complex for my use case... thanks anyway for response Nic.

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 17, 2016

Ah, I think I've misread the requirement - I've assumed you wanted variables where you can change them in one place, and have them automatically shown correctly in other places.

But what you want is "put X on several pages, and have it display differently according to some other stuff, such as the space the page is in"?  If that's right, then my first three won't help you, but user macros can do that.  (macro X with would contain decision logic on what to actually display)

Tomasz Glinski February 18, 2016

What I want is much easier: I maintain a page, where some IP number appears many times, and I would like to be sure, that when it changes, all its occurences change. So intstead directly writing it everywhere, I would like to put there a constant instead, and define this constant value at the beginning, once.

Sure, I could kinda achive that by "replace all" in text editor, but would like to do it more "pro" wink

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 19, 2016

Yes, that makes sense.  I suppose you could do something with page properties (I'm not sure, I've only ever used them for doing stuff with other pages), and I suspect, again, a user macro might be able to help.  You need something that allows you to put some form of metadata on the page and then expose it whereever you want in the page.

Tomasz Glinski February 23, 2016

Ok, thanks Nic for clarifications. Hope Confluence will get that kind of functionality someday cheeky

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events