Category Templates And Newpage

By hellekinhellekin

Description

The NewPage Module requires that you use a template: category, otherwise it complains that your template doesn't exist.
However, the newer template system make them sit at category:_template.

Fortunately, you can mix the two to obtain what you want!

Let's say we have a wooza category. We made a nice template sitting at wooza:_template:

+ %%category%%: %%page_name%%
by %%author%% (%%comments%% comments)

Wooza! Wooza %%content{1}%%

++ Wikidot rules!

%%content{2}%%

------------
[[module Comments]]

====

This is default content 1

====

This is default content 2

Code

Create a template:wooza page so that the NewPage module doesn't complain.

[[include wooza:_template]]

In action

Now, you can use:

[[module NewPage category="wooza" template="template:wooza" button="w00t!"]]

See it live on http://hackerspace.net/

Notes

In order to provide default values for templates:

  • the template: system uses variables
  • the category:_template system uses %%content{n}%% instead: this is what you should use.

Rate this solution

If you think this solution is useful — rate it up! Or dump it otherwise.

rating: +1+x
Sorry but ...
gerdamigerdami 1233686961|%e %b %Y, %H:%M %Z|agohover

… it would be enough with

wooza:_template

+ %%category%%: %%page_name%%
by %%author%% (%%comments%% comments)

Wooza! Wooza %%content{1}%%

++ Wikidot rules!

%%content{2}%%

------------
[[module Comments]]

and

template:wooza

This is default content 1
====
This is default content 2

and elsewhere

[[module NewPage category="wooza" template="template:wooza" button="w00t!"]]
unfold Sorry but ... by gerdamigerdami, 1233686961|%e %b %Y, %H:%M %Z|agohover
Re: Sorry but ...
hellekinhellekin 1233763132|%e %b %Y, %H:%M %Z|agohover

Ah! Thanks you for the heads up.

I'm a newbie with Wikidot and couldn't find any documentation on that.

So, you advise to put the template inside category:_template and the defaults inside template:category

Interesting. But I'm not sure how it's better than putting all into one place. Can you explain a bit more why it would be wiser?

Cheers!

unfold Re: Sorry but ... by hellekinhellekin, 1233763132|%e %b %Y, %H:%M %Z|agohover
Re: Sorry but ...
gerdamigerdami 1233771298|%e %b %Y, %H:%M %Z|agohover

The wazoo:_template can be changed at wish. When saving a new version of the _template, Wikidot recompiles all existing pages of the wazoo category. With many many pages, it can take a while.

The template:wazoo is not mandatory at all, it just helps, at new page creation, to remind that the page actually needs a content{1} and a content{2} (to follow the example you gave).

unfold Re: Sorry but ... by gerdamigerdami, 1233771298|%e %b %Y, %H:%M %Z|agohover
Re: Sorry but ...
hellekinhellekin 1233812455|%e %b %Y, %H:%M %Z|agohover

Hey that makes a lot of sense. Thanks again for the explanation.

unfold Re: Sorry but ... by hellekinhellekin, 1233812455|%e %b %Y, %H:%M %Z|agohover
The reason is the "Live" template used
Helmuti_pdorfHelmuti_pdorf 1233767292|%e %b %Y, %H:%M %Z|agohover

With an existing "live" template ( categoryxyz:"_template") there is the "default" given with the content after the first "=====" line.

means - in such a case you need not a "standard" template ( "old" format "template:"categoryxy) for a "newpage" module..

Documentation: http://www.wikidot.com/doc:templates


Service is my success. My webtips:www.blender.org, www.zusi.de (Demo-Video)

Wollen Sie Wikidot helfen im deutschen » Handbuch ?

unfold The reason is the "Live" template used by Helmuti_pdorfHelmuti_pdorf, 1233767292|%e %b %Y, %H:%M %Z|agohover
Re: The reason is the "Live" template used
hellekinhellekin 1233812574|%e %b %Y, %H:%M %Z|agohover

It might be the lack of sleep but I didn't get anything from your entry. Did you update the docs? I read them before posting the tip, but couldn't find anything useful regarding the use of _template with the NewPage module (which was breaking).

unfold Re: The reason is the "Live" template used by hellekinhellekin, 1233812574|%e %b %Y, %H:%M %Z|agohover
Add a new comment
page_revision: 2, last_edited: 1233631335|%e %b %Y, %H:%M %Z (%O ago)
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License