Clipboard

Summary: Include content on another page
Version: v0.50
Status:
Prerequisites: at least PmWiki version: 2.0, last tested on PmWiki version: 2.10
Maintainer: J. Meijer
Discussion: Clipboard-Talk
Categories: Images

Get it here: clipboard.phpΔ

Questions

  1. How do I put text or images into the SideBar depending on the current page?
  2. How do I make resources available to pages in a group?
  3. How do I make a gallery?
  4. Include content on another page (f.e. RecentChanges) and format it into a table

Answers

  1. Define a clip using (:cut:) in the page and (:paste:) it into the SideBar. No need to use (:if:).
  2. Create a page named GroupClipboard in the group and put your resources there. Then paste them from whereever you want.
  3. Use (:for:) to expand image-names into the page-text needed to display the gallery You want. The gallery can be defined in an XLPage or GroupClipboard.
  4. Use (:paste:) and set the number of columns. One could use the 'extract=' parameter to select certain page elements.

Cut and Paste markups added

A clip is any text, that is treated by this plugin as a series of lines.

(:cut:)
Full syntax: (:cut clipname:)...(:cutend[ clipname]:). Any text between the markups is removed from the pagetext and stored into clip <clipname>.
(:copy:)
Full syntax: (:copy clipname:)...(:copyend[ clipname]:). Any text between the markups is copied from the pagetext and stored into clip <clipname>.
(:copy clipname Group.Page#clipname2:)
A clip named <clipname> is copied from clip <clipname2> defined in page Group.Page. Or all of page group.page when #clipname2 is absent.
(:paste clipname:)
Replaces itself by clip <clipname>.

The clipname in (:cutend:) and (:copyend:) is optional.
Clipname can be Group.Page#clipname, so any clip from any page can be imported.

Controlling clips

Copy and Paste can take a number of parameters, allowing some control over the clip:

  • extract=<regular expression>: extracts parts denominated in <regular expression>
  • id=<name>: extracts lines beginning with '<name>:', sections beginning with '! name', or table rows beginning with '||name'
  • lines=3..5: get lines 3..5 only
  • 'sort' and 'reverse': sort and reverse the list. Markup will confuse sorting.
  • list=bullet, list=enumerated, list=enum: output the clip as a list of the requested format
  • columns=4: output as table with 4 columns

The parameters are processed in the order shown.

Storage of clips

Clips are stored in $XL['clip']['clip-<clipname>'] where <clipname> should be substituted with the name of the clip. You could load an XLPage in your config.php setting $XL['clips'] from that page.

You can also set clips from the url by preceeding the clipname with 'clip-'. F.e.

  pmwiki.php?n=Group.Page?clip-myclip=mycliptext

Makes myclip available to the page. You can then paste it into the page-text and thus personalize the page.

Testing for clips

To test is clip myclip exists write (:if clip myclip:).

Template filling markups

Clips can be used as templates and filled from a list or another clip.

(:foreach clipname1 do clipname2:)
for each line in clipname1 fill the template in clipname2
(:foreach name1,name2,name3 do clipname:)
for each of name1, name2 and name3 fill the template in clipname. Note: Instead of the namelist you can write {$Targets} to use the list of links at the page.

Within the template (:item:) is replaced by the current item (line), and (:index:) by the current line-number. You can place (:begin:) and (:end:) markups to limit expansion to the delimited areas. As an example, this clip (formatted for inclusion into an XLPage) implements a small gallery template:

'clip-gallery' => '(:nl:)||border=1 cellspacing=0 (:nl:)(:begin:)|| %thumb newwin% [[Attach:(:item:).jpg | Attach:(:item:).jpg]] (:end:)'

To use it to make two rows of 5 thumbnails you write:

(:for foto1,foto2,foto3,foto4,foto5 do gallery:)
(:for foto6,foto7,foto8,foto9,foto10 do gallery:)

Note: no need to specify .jpg extensions, this is taken care of.
Note: it would be nice if pagelists could dump their result in a clip, so a range of pages can act as the data-source for template filling. Soon to be added.

Notes

  • This recipe, version 0.50 was installed here October 4th, 2005

Releases

  • v0.50 Just the initial release. Defines (:cut:), (:copy:), (:paste:) and (:for:) markups, as well as clip-testing and setting clips from the url.

Author's note:

Changes to API expected soon.

I'll be mostly off-line.

See Also

Special purpose scripts:

Email introducing basic (non-template) features: clipboard.txtΔ

Comments

See discussion at Clipboard-Talk

User notes : If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.