Category Templates And Newpage

By hellekin hellekin

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.

Thanks to tsangk for this great snippet: conditional-blocks


text above inserted with:

[[include :snippets:if START |unique=1|type=equal|var1=%%name%%|var2=conditional-blocks]]
**##red|Thanks to tsangk for this great snippet:##** [[[code:conditional-blocks]]]
[[include :snippets:if END]]



Other snippets posted by hellekin


Rate this solution

If you think this solution is useful — rate it up!

rating: +6
The reason is the "Live" template used
Helmut_pdorf Helmut_pdorf 04 Feb 2009 17:08

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 (Open source), Wikidot-Handbook.

Sie können fragen und mitwirken in der deutschsprachigen » User-Gemeinschaft für WikidotNutzer oder
im deutschen » Wikidot Handbuch ?

by Helmut_pdorf Helmut_pdorf , 04 Feb 2009 17:08
Re: The reason is the "Live" template used
hellekin hellekin 05 Feb 2009 05:42

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).

by hellekin hellekin , 05 Feb 2009 05:42
Sorry but ...
gerdami gerdami 03 Feb 2009 18:49

… 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!"]]
by gerdami gerdami , 03 Feb 2009 18:49
Re: Sorry but ...
hellekin hellekin 04 Feb 2009 15:58

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!

by hellekin hellekin , 04 Feb 2009 15:58
Re: Sorry but ...
gerdami gerdami 04 Feb 2009 18:14

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).

by gerdami gerdami , 04 Feb 2009 18:14
Re: Sorry but ...
hellekin hellekin 05 Feb 2009 05:40

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

by hellekin hellekin , 05 Feb 2009 05:40
page revision: 3, last edited: 15 Feb 2012 00:27
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License
Click here to edit contents of this page.
Click here to toggle editing of individual sections of the page (if possible). Watch headings for an "edit" link when available.
Append content without editing the whole page source.
Check out how this page has evolved in the past.
If you want to discuss contents of this page - this is the easiest way to do it.
View and manage file attachments for this page.
A few useful tools to manage this Site.
Change the name (also URL address, possibly the category) of the page.
View wiki source for this page without editing.
View/set parent page (used for creating breadcrumbs and structured layout).

AltStyle によって変換されたページ (->オリジナル) /