Question
Is it possible to get a non-existent
WikiWord to use a template specific to one topic?
For example:
Suppose I have two topics on a page:
When I click on the "?" next to
AppleTree, I want TWiki to apply the
AppleTreeTemplate; when I click on
GrapeVine, I want TWiki to apply the
GrapeVineTemplate. The templates are defined elsewhere.
Both of these topics are (currently)
non-existent. The "?" following is the expected behaviour.
I have tried defining AppleTree as:
[[AppleTreeTemplate?templatetopic=AppleTreeTemplate][AppleTree]]
... but it doesn't work. TWiki strips the "?" out. I have also tried escaping the ? with a \ and putting it in quotes.
Any ideas? Is it
possible?
- TWiki version: Dec 2001
- Web server: Apache
- Server OS: Solaris
- Web browser:
- Client OS:
--
CoreyFruitman - 16 Apr 2002
Answer
Try a complete URL:
[[%SCRIPTURL%/edit%SCRIPTSUFFIX%/%WEB%/AppleTreeTemplate?templatetopic=AppleTreeTemplate][Edit]] _AppleTree_
--
PeterThoeny - 17 Apr 2002
Follow-up
I'm looking for the dynamic edit/view behaviour that TWiki normally offers. The solution above will only edit.
Is it possible the make it so that if the topic exists, it will view, if not it will edit using the AppleTreeTemplate?
--
CoreyFruitman - 17 Apr 2002
Do you want to use different templates (based on new page name) without having to fully specify template while creating new page (as
PeterThoeny suggested)? I guess you plan to have a lot of pages of each kind, right? You may have only one default template per web (IIRC), so you can have web
Apples
, with
AppleTreeTemplate
, and web
Grapes
, with
GrapeVineTemplate
. Makes sense?
Even simpler option is: create
AppleGrapeTemplate
, and train user to delete, what is not appropriate. Deleting is
much faster that typig.
--
PeterMasiar - 17 Apr 2002
Yes, I'd like to use one template per word, but the template needs to be context sensitive. So, in short, whatever the word being edited is, its edit function is called with a template that is composed of % TOPICBEINGEDITED %+ "Template".
I have a feeling that this isn't possible within the existing TWiki framework. Can anyone confirm?
--
CoreyFruitman - 17 Apr 2002
I am missing something again. The way you proposed, you will be able to create from one template only one page (stripping
Template
from template name). It does not make sense to me.
I am also lost what you meant with
I'd like to use one template per word, but the template needs to be context sensitive. Templates are explained in
TWikiTemplates.
If you click on
WikiWord: If page exists, it will be viewed, and visual part (header, footer etc) of it is handled by
TWikiSkins. If page does not exist, it will be created, and
contens of new page will come from default (for web) template. You may also edit page using hack
PeterThoeny proposed, and if page does not exist, it will be created using proper template. If exists, web's skin defines look of the page.
You have default template for the web, or template on demand using
templatetopic
parameter.
If you are want TWiki to use part (i.e. 1st word) of WikiName as base for template - yes, it can be done, but nobody needed it yet. It will be a new feature. Fortunately, you have source code to tweak it more...
Simple solution is to place pages based on different templates into different webs.
--
PeterMasiar - 18 Apr 2002
This (above in red) is what I was looking for.
Thanks very much for the info.
--
CoreyFruitman - 18 Apr 2002