If you want to insert a wiki page into another page you use the InsertPage plugin. The following code demonstrates the basic technique. Of course, first you need the page to be inserted; we'll use InsertPageTest.

Inserting an entire page#

This
Here, I insert the text of another page:\\
[{InsertPage page=InsertPageTest}]

produces this

Here, I insert the text of another page:

ffff

Naming convention reminder#

When you include the name after the = sign, do not include white space {i.e., blanks}. Also, if you had a quote, such as with a possessive like [Writer's Notes] remember to use the name as stored. That is, remember the capital letter such as [WriterSNotes].

Inserting a section of a page#

If you want to insert a section of a page into another page use a horizontal ruler (four dashes, '-') to part sections. The page InsertPageTestSections contains three sections that is included below:

This

Here, I insert section 3 of another page:\\
[{InsertPage page=InsertPageTestSections section=3}]

produces this

Here, I insert section 3 of another page:
Plugin insertion failed: There is no section no. 3 on the page.

Inserting a page into itself - Circular reference#

Cyclical dependencies are checked for, so inserting a page into itself won't work. If I try to insert this page into itself you get the entire page along with an error message as follows:

If you want to insert a wiki page into another page you use the InsertPage plugin. The following code demonstrates the basic technique. Of course, first you need the page to be inserted; we'll use InsertPageTest. Table of Contents

Inserting an entire page#

This
Here, I insert the text of another page:\\
[{InsertPage page=InsertPageTest}]

produces this

Here, I insert the text of another page:

ffff

Naming convention reminder#

When you include the name after the = sign, do not include white space {i.e., blanks}. Also, if you had a quote, such as with a possessive like [Writer's Notes] remember to use the name as stored. That is, remember the capital letter such as [WriterSNotes].

Inserting a section of a page#

If you want to insert a section of a page into another page use a horizontal ruler (four dashes, '-') to part sections. The page InsertPageTestSections contains three sections that is included below:

This

Here, I insert section 3 of another page:\\
[{InsertPage page=InsertPageTestSections section=3}]

produces this

Here, I insert section 3 of another page:
Error: Circular reference - you can't include a page in itself!

Inserting a page into itself - Circular reference#

Cyclical dependencies are checked for, so inserting a page into itself won't work. If I try to insert this page into itself you get the entire page along with an error message as follows:

Error: Circular reference - you can't include a page in itself!

A Bug?#

I think the cyclical dependency check is a bit overzealous. If you try to insert a page more than once on the same page, it flags an error. For example, because earlier on this page there was an InsertPage for InsertPageText, the another link to it will break:

ffff

Seems to be working in 2.3.50...

A Bug if the name of the target page contains an underscore#

The following should say something like "this is an inserted page, with a name containing an underscore". If , instead, you see the "do things right text", it means there is either

  • a bug, or
  • I haven't understood correctly how to insert pages with names that contain underscores.
Inserted text:
This is an inserted page where the name of the page has an underscore

It seems to be an issue in the parser, which considers "_" to be a stop word, just like a comma or a dot. Workaround: enclose the page name in single quotes. I.e.

[{InsertPage page='InsertPageTest_WithUnderscore'}]

instead of

Inserted text: [{InsertPage page=InsertPageTest_WithUnderscore}]

So far as I know, the convention on JSPWiki plugins is to surround all parameter values with single quotes, so in documentation I'd recommend we also recommend the same. I certainly write all my plugins (and parsers for my plugins) to require single quotes. It's generally better to be consistent rather than flexible — at least less confusing for users — so nobody ever has to ask "should I be delimiting my parameters?" The answer is then always "yes".

-- MurrayAltheim

A Bug?#

I think the cyclical dependency check is a bit overzealous. If you try to insert a page more than once on the same page, it flags an error. For example, because earlier on this page there was an InsertPage for InsertPageText, the another link to it will break:

ffff

Seems to be working in 2.3.50...

A Bug if the name of the target page contains an underscore#

The following should say something like "this is an inserted page, with a name containing an underscore". If , instead, you see the "do things right text", it means there is either

  • a bug, or
  • I haven't understood correctly how to insert pages with names that contain underscores.
Inserted text:
This is an inserted page where the name of the page has an underscore

It seems to be an issue in the parser, which considers "_" to be a stop word, just like a comma or a dot. Workaround: enclose the page name in single quotes. I.e.

[{InsertPage page='InsertPageTest_WithUnderscore'}]

instead of

Inserted text: [{InsertPage page=InsertPageTest_WithUnderscore}]

So far as I know, the convention on JSPWiki plugins is to surround all parameter values with single quotes, so in documentation I'd recommend we also recommend the same. I certainly write all my plugins (and parsers for my plugins) to require single quotes. It's generally better to be consistent rather than flexible — at least less confusing for users — so nobody ever has to ask "should I be delimiting my parameters?" The answer is then always "yes".

-- MurrayAltheim

Add new attachment

Only authorized users are allowed to upload new attachments.
« This page (revision-76) was last changed on 11-Jun-2010 00:25 by Janne Jalkanen