IncludePara
<< | Cookbook-V1 | >>
Note: The recipes here are for PmWiki versions 0.6 and 1.0 only. For PmWiki 2.0 recipes, see Cookbook.
Including only a selected paragraph from another page
Goal
Include a selected paragraph from another page on the current page.
Solution
Attach:includepara.php - PHP code
Adds the following markup to PmWiki/PmWiki:
- Markup that inserts the name of a page, PageName, followed by the first paragraph of that page. This markup comes in three versions that inserts either a bulleted item, a numbered item or a definition list item.
The markup must be first on a line and looks like this:T*PageName
(bullet item)T#PageName
(numbered item)T:PageName
(definition item)
- The directive
[[para:WikiWord]]
inserts the first paragraph of the page referred to by PmWiki/WikiWord. - The directive
[[para:WikiWord#anchor]]
inserts the paragraph of the page referred to by PmWiki/WikiWord, that immediately follows the anchor[[#anchor]]
.
Note: This markup works with free links? and across groups.
Note: When including a paragraph, any markup at the beginning of the paragraph such as !, # or * is not included.
Note: When the first paragraph begins :term:some text ...
, the markup returns some text ...
Instructions
Add the line include_once("local/includepara.php");
in the local.php file.
- Example 1
- T*FootNotes produces
- FootNotes: Goal
- Example 2
- The first paragraph of FootNotes is
[[para:FootNotes]]
produces - The first paragraph of FootNotes is Goal
- Example 3
- If the first paragraph of FootNotes is
- Goal
- Provide support for footnotes and intra-page cross-references.
- The first paragraph of FootNotes is
[[para:FootNotes]]
produces - The first paragraph of FootNotes is Provide support for footnotes and intra-page cross-references.
Revision History
Released 19 August 2003
Revised 1 October 2003: add support for double bracketed links following T markup.
Discussion forum
At the moment, T*
is only available as a first level item, I'd like to have T**
produce a second level item. Then I could use this kind of markup:
T*IncludePara T**IncludePara T***IncludePara
producing:
- IncludePara: Including only a selected paragraph from another page
- IncludePara: Including only a selected paragraph from another page
- IncludePara: Including only a selected paragraph from another page
- IncludePara: Including only a selected paragraph from another page
An alternative markup (and more intuitive) might be *T*
and **T*
.
-- Christian Ridderström, 2003-11-30
See Also
- FootNotes
Contributors
- John Rankin
I wanted to change this to be able to include all of a page up to an anchor. This is so that I can include only new news items on my front page. To do this I've added the following lines to this script:
Attach:includepara_MDS.php.txt - Modified PHP code
So to include all news items up to the anchor "#oldnews" you would add:
[[topara:NewsItems#oldnews]]
I hope someone else finds this useful!
-- Matthew Shaylor 12th March 2004 pmwiki-2.3.38 -- Last modified by {{Matthew Shaylor}}?