View Full Version : web.link question
rickyhow
09-02-2008, 08:23 PM
This creates a link to Step 3, but the text for the link is the common ancestor (page.parent).
{{ web.link{uri: page.parent.uri.."/Step_3", text:page.parent.title} }}
Anyone know how I could change the text argument so that it references the Step_3 page?
brigettek
09-02-2008, 09:24 PM
Can't you just use the following?
{{ web.link{uri: page.parent.uri.."/Step_3"} }}
or
{{ web.link{uri: page.parent.uri.."/Step_3", text:"Step 3"} }}
rickyhow
09-02-2008, 09:34 PM
If I use the first option I get the full path. If I use the second option and the page name that I am linking to is changed, then the text may no longer be appropriate.
If I use page.parent.title I almost get what I am looking for - except that it is the name of the parent.
I just need to be able to get the name of page by building a path to it.
brigettek
09-02-2008, 09:45 PM
This will give you the title of a page at a given path:
{{ wiki.getpage(page.parent.uri.."/Step_3").title }}
rickyhow
09-02-2008, 10:29 PM
Yes that does it - I just needed to make one change (path rather than uri for wiki.getpage).
{{ web.link{uri: page.parent.uri.."/Step_3", text: wiki.getpage(page.parent.path.."/Step_3").title} }}
Thank-you kindly Brigettek!
SteveB
09-05-2008, 02:20 PM
It looks like you may need this code fragment several times (maybe as part of an instruction manual or something).
You can save yourself some typing and reduce errors by putting it into a template, like this:
Template:StepLink
{{ var p = wiki.getpage(page.parent.path .. "/" .. $0); web.link{uri: p.uri, text: p.title} }}
Now, to use it on the target page, just use this:
To go to the next step click on {{ template.steplink("Step3") }}.
rickyhow
09-07-2008, 10:11 PM
Thank-you much appreciated...
Powered by vBulletin™ Version 4.1.3 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.