[pmwiki-users] Recipe suggestion?

Peter Bowers pbowers at pobox.com
Tue Sep 30 05:11:34 CDT 2008


>  I have an idea and need help in making it reality. What I'd like to do
> is have a list of pages and have that list display the PageTitle and
> first 20 or so words of the page content and have that followed by a
> "Read more" link that links to the actual page.

See fmt=#teasers or fmt=#headerinclude or fmt=#articleteaser on this page -
very close to what you're looking for:

http://www.pmwiki.org/wiki/Cookbook/PagelistTemplateSamples

The difficulty you will find is getting 20 non-markup words.  The (:include
... lines=x:) will give you x lines of source, but they may include the
(:title ...:) or other markup that would be undesirable and it is
line-centric rather than word-centric (maybe that's OK?).

You will also potentially run into the limit of 50 includes per page if your
pagelist returns more than that number of pages.

You might try Hans's {(TextExtract ...)} or WikiSh's {(sed ...)} as an
alternative to (:include ...:) as they both have options to suppress markup,
but neither of them supports x WORDS in a manner that is "out of the box".
(Hans, you can correct me if I'm wrong on that -- I didn't see it on a
cursory look through the documentation.)  They both would also avoid the
difficulty with the maximum of 50 includes.

-Peter

PS Further non-tested comments below:

Something like this would probably work from a WikiSh perspective as long as
the 20 words are all on the first line of source (lines of source as broken
by a newline/enter):

{(sed -n --markup:code -e 1p -e 's/^\\s*(?:\\S+\\b\\s*){1,20}.*/$1/'
{=$FullName})}

I believe that TextExtract has more elegant ways to "cut" markup, but I'm
not familiar with the exact syntax, so you'd have to check that out.






More information about the pmwiki-users mailing list