You are currently reading the page [{$pagename}].
produces this
You are currently reading the page HowToUseAVariable.
ErikAlm, 09-Jun-2005:
I'm trying to do:
[MoreInfo[{$pagename}]]In order to create an automated WikiName linking from one page to another page (in this case with more info on whatever subject 'this page' is about). My rationale for this is that I want to put this code in one page and then include this page in another page and get an automatic link to "MoreInfoMyPage".
However
[MoreInfo[{$pagename}]]Produces:
And
[MoreInfo{$pagename}]Also, does not do the trick:
As we might expect,
[MoreInfo$pagename]Is also not the way to do it:
I'm guessing variables cannot be used in this way, or did I miss something?
Um, at the moment no. I was going to add this functionality soonish, though, but I had too many bug fixes to do. A patch would be appreciated ;-)
Lets pretend the code on one page called TestPage is
Hello [{$tname}]Then the code for another page called Tester is
[{SET tname='Stephen'}] [{InsertPage page='TestPage'}]It doesnt seem to be working as I would expect. I would expect the output to be
Hello Stephenbut instead I get
Hello No such variable: No variable tname defined.What am I doing wrong? Why is InsertPage parsing the content of the inserted page prior to insertion? --Stephen
The tname variable is referring to the page variable called "tname" on page "Tester". Variables are always interpreted in the context of the including page, not the included page. This allows you to e.g. create templates which you can insert and control with page variables.
If variables are interpreted in the context of the including page why does Tester claim not to know what tname is when inserting a page that references that variable? Controlling a inserted page through page variables is EXACTLY what I am trying to do. But if all page variables defined in the including page lose scope prior to insertion then I fail to see how this is possible? Is it possible to directly manipulate the variables for a page prior to insertion?
-- Stephen
This could be a bug.
--JanneJalkanen, 22-Sep-2007
Assigning variables