Clipboard
(redirected from Cookbook.ClipBoard)
Get it here: clipboard.phpΔ
Questions
- How do I put text or images into the SideBar depending on the current page?
- How do I make resources available to pages in a group?
- How do I make a gallery?
- Include content on another page (f.e. RecentChanges) and format it into a table
Answers
- Define a clip using (:cut:) in the page and (:paste:) it into the SideBar. No need to use (:if:).
- Create a page named GroupClipboard in the group and put your resources there. Then paste them from whereever you want.
- 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.
- 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:)
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.