[Pmwiki-users] How to break text . . .

John Rankin john.rankin
Sun Jul 11 23:02:05 CDT 2004


On Monday, 12 July 2004 3:15 PM, Ben Wilson <pmwiki at dausha.net> wrote:
>It's close to what I want, about an 80 percent solution. Allow me to
>restate my goal.
>
>I want a full page of text that has a break tag embedded in it (probably
>a DoubleBracket). When that page is included on another page, then only
>the text prior to the break tag is visible. The break tag itself is
>converted to a "Read More". This allows for the top segment of a page to
>be used as teaser material in another page.
>
>With this approach in mind, I could have a series of complete articles,
>and a single page where they are "included" with the abbreviated text
>being visible. This would allow for a blog-like approach where you get
>to pick and chose the articles and their order.
>
>I think what I need to figure out is how to "substitute all text after
>the tag with a 'read more' link."
>
>Ben
>
>
You have at least 2 options:

1. If having just the first paragraph of your articles is 'good enough'
   then you don't need to do anything with the pages themselves. Use
   the teaser script and on your introductory page write:

        [[para:SomePage]] [[SomePage Read more...]]

   You can create a short-cut for this by adding the following line
   *before* you include teaser.php:

        $DoubleBrackets["/^P:(($GroupNamePattern[.\\/])?$PageTitlePattern)$/"] =
            "[[para:$1]] [[$1 Read more...]]";

   Then you can write on your introductory page, on a line by itself:

        P:SomePage

   I just picked P: as a handy letter (P for para and P for page)

2. If you need arbitrary amounts of text from the articles, insert an
   anchor of the form [[#breakpoint]] where you want the article to
   break and on your introductory page write:

        [[include:SomePage##breakpoint]] [[SomePage Read more...]]

   The 2 ## tells include to return the start of the page to the anchor
   AFAIK, the short-cut trick won't work in this case, because
   include directives get processed before $DoubleBracket directives.
   This approach works 'out of the box' -- no extra recipes are needed.

   However, it would be pretty trivial to modify the teaser script
   so you can write (for example):

        [[more:SomePage#breakpoint]]

   and it produces exactly the output you want.

Hope this helps.

-- 
JR
--
John Rankin





More information about the pmwiki-users mailing list