Are there page scoped variables/constants?

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 vote

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

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.

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)

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

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.

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
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Thursday in Confluence

Three common content challenges + how to manage them

An efficient enterprise content management system, or ECM, is a must-have for companies that create work online (cough   cough, all companies). If content calendars, marketing plans, and bu...

73 views 0 4
Read article

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