Are there page scoped variables/constants?
Asked by Tomasz Glinski:

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/](http://123/gui)`admin`

`sthOther: 123.123.123.`[123:9091/](http://0.0.0.123/gui)`sthOther`

`sthOther2: 123.123.123.`[123:9092/](http://0.0.0.123/gui)`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?


Answers:
author: Nic Brough -Adaptavist-
body: 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

comments: author: Tomasz Glinski
body: 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.


author: Nic Brough -Adaptavist-
body: 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)


author: Tomasz Glinski
body: 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:


author: Nic Brough -Adaptavist-
body: 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.


author: Tomasz Glinski
body: Ok, thanks Nic for clarifications. Hope Confluence will get that kind of functionality someday ![cheeky](/html/@FAF1B8ED81FE63CF2DF635B2383CF9FB/images/emoticons/cheeky.png "cheeky")