create new tag
, view all tags


We have an on-going requirement to create topics as a sub-set of sections from other topics. The 'parent' topic is generated from a template and so the sections are standard. The 'child' topic is required to inherit some of those sections.

I have set up a second template to generate the child topic from the parent. The issue is that each instance of the parent topic has a different name, so I need some way of passing the parent file name into the template, so it can use that name to get the information.

I have tried using %include{}%, but have not been able to pass a file name into the include, i.e,

The template currently looks like this -

%INCLUDE{"file_name" section="Build Details"}%

and I'm assuming it needs to look something like

%INCLUDE{var(file_name) section="Build Details"}%

I'm creating the topic using -

<form name="newtopic" action="%SCRIPTURLPATH%/edit%SCRIPTSUFFIX%/%INTURLENCODE{"%WEB%"}%/">
   * Build number: 
     <input value="e.g. IVADSL-2-4-3-0" name="topic" type="text"></input>
     <input type="hidden" name="templatetopic" value="grbtestinclude" />
     <input type="hidden" name="topicparent" value="%TOPIC%" />
     <input type="hidden" name="onlynewtopic" value="on" />
     <input type="submit" value="Create" />

and was then trying to access the value of "topicparent" in the child template, but to no avail.

Thanks in advance for assistance.


TWiki version: TWikiRelease04x00x05
TWiki plugins: DefaultPlugin, EmptyPlugin, InterwikiPlugin
Server OS:  
Web server:  
Perl version:  
Client OS:  
Web Browser:  

-- GavinBloomer - 09 Jan 2007


ALERT! If you answer a question - or someone answered one of your questions - please remember to edit the page and set the status to answered. The status selector is below the edit box.

Not sure if this works, but to get the parent of a topic you can do %META{"parent" dontrecurse="on"}%. So, you might be able to use this in your include statement, like %INCLUDE{ %META{"parent" dontrecurse="on"}% section="Build Details"}%.

Failing that there is the TopicCreatePlugin which allows you to pass parameters to a child topic when a topic is created. Don't think this will help too much in your case though.

-- AndrewRJones - 09 Jan 2007

Andrew, thanks for your suggestions. I tried the first part, which seems to work, except that

does not like
%META{"parent" dontrecurse="on"}%
as a parameter, it returns -
Note: Included topic GrbTest?section=BuildDetails]] does not exist yet 

If I include

%META{"parent" dontrecurse="on"}%
on a line on its own, it resolves OK.

-- GavinBloomer - 09 Jan 2007

You can try a search. There is one here that is supposed to give the parent: SearchPatternCookbook#Pattern_4_Extract_the_parent_of, though I find these sort of topics tend to get out of date.

Other than that I'm afraid I don't have any more ideas.

-- AndrewRJones - 10 Jan 2007

Since you are passing the topic parent as a URL parameter you can simply access it with %URLPARAM{topicparent}%. Note that TWiki will replace URLPARAM with it's value (see TWikiScripts#edit)

-- PeterThoeny - 11 Jan 2007

Thanks Peter, that did the job.

Only thing to remember is that line should read -

%INCLUDE{"%URLPARAM{topicparent}%" section="Build Details"}%

and not

%INCLUDE{%URLPARAM{topicparent} section="Build Details"}%

i.e. "" around

which threw me a bit at first.

-- GavinBloomer - 11 Jan 2007

I am trying to use this. It is fine when I view in PREVIEW but when I save from editview, in view, there is a line that says

Warning: Can't find topic "".""

Any ideas?

-- XochipalaValdez - 26 Mar 2007

Got me stumped. Here's my test topics if that helps: (I'm testing this on 4.1.2, which is different than your version)


<form name="new" action="%SCRIPTURLPATH{edit}%/%WEB%/">
   * New example topic: 
     <input type="text" name="topic" value="ExampleTopic%SERVERTIME{$yearx$mox$day}%" size="26" />
     <input type="hidden" name="templatetopic" value="IncludeParentTemplate" />
     <input type="hidden" name="topicparent" value="%TOPIC%" />
     <input type="hidden" name="onlywikiname" value="on" />
     <input type="hidden" name="onlynewtopic" value="on" />
     <input type="submit" class="twikiSubmit" value="Create" />
     (date format is <nop>YYYYxMMxDD)








-- JustinLove - 01 Apr 2007

in the template topic, where you have the include statement, it will try to resolve the urlparam, even if there isn't one. To make sure it works, you can put a ?topicparent= in your view url. If it works then, you can remove the warning, assuming it bothers you, by using the warn="off" or "no" option of include. Hope that helps.

-- MatthewCardozo - 25 Apr 2007

Closing this after more than 30 days inactivity; re-open if needed...

-- PeterThoeny - 02 Jun 2007

Change status to:
Edit | Attach | Watch | Print version | History: r11 < r10 < r9 < r8 < r7 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r11 - 2007-06-02 - PeterThoeny
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2018 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.