[pmwiki-users] Unwanted carriage return with pagelist template

Benoit Dutilleul benoit.dutilleul at googlemail.com
Tue Mar 27 12:53:00 CDT 2007


Thanks for this extensive answer! It explains a lot of "behaviours" I
observed. The markup output type would definitely be very useful to me. I
find the synthax you propose straightforward.

Thanks,

Benoit


2007/3/27, Patrick R. Michaud <pmichaud at pobox.com>:
>
> On Tue, Mar 27, 2007 at 11:33:55AM +0200, Benoit Dutilleul wrote:
> >    Dear all,
> >
> >    I've defined a pagelist template to output the number of entries of a
> >    query.
> >    [[#PageCount]]
> >    (:if equal {>$Group}:){$$PageCount}(:ifend:)
> >    [[#PageCountend]]
> >
> >    However, when I use it, I have an unwanted carriage return.
> >
> >    Example:
> >    "You website has [template] numbers" outputs:
> >
> >    Your website has 4
> >    members
> >
> >    Any idea how I can fix this?
>
> First, a possibly "simple" answer:
>
>     [[#PageCount]]
>     (:template last:)
>     Your website has {$$PageCount} members
>     [[#PageCountend]]
>
> The long answer: The output of pagelist generally comes in a
> <div>...</div> wrapping, so that's probably what is causing the
> linebreak in the output.  And even if we can get rid of the <div>,
> the standalone "4" is still going to end up enclosed in its own
> paragraph (<p>...</p>) so we'd still have some difficulty there.
>
> The topic of inline pagelists recently came up in [1]... and at
> the conclusion of that thread we proposed adding a 'tag=' option
> to specify 'div', 'span', or 'none' for the outer wrapping of
> the pagelist template.
>
> That takes care of the outer tag, but the inner (<p>) one
> still remains.
>
> Today, in another message [2], we've also encountered a case
> where someone wants (:pagelist:) to return the markup to its
> enclosing page instead of rendering it directly to html.  It would
> be good to support this option as well.
>
> [1]
> http://thread.gmane.org/gmane.comp.web.wiki.pmwiki.user/39693/focus=40130
> [2] http://www.pmichaud.com/pipermail/pmwiki-users/2007-March/040971.html
>
> So, instead of a 'tag=' option, I now propose an 'outputtype=' option:
>
>     outputtype=div          # return pagelist as <div>...</div> (current
> default)
>     outputtype=span         # return as <span>...</span>
>     outputtype=html         # return as html, no outer wrapper
>     outputtype=markup       # return as markup (don't convert to HTML)
>
> The above template to return a page count could then be done as:
>
>     [[#PageCount]]
>     (:template outputtype=markup:)
>     (:template last:)
>     {$$PageCount}
>     [[#PageCountend]]
>
> such that the pagecount ends up being inserted directly in the markup
> (along with various carriage returns, that shouldn't result in
> lines in the output).
>
> Another option that avoids the template altogether is to write a custom
> fmt=count option for pagelist to return the count.  This would be:
>
>     function FPLCount($pagelist, &$matches, $opt) {
>       $matches = array_values(MakePageList($pagename, $opt, 0));
>       return count($matches);
>     }
>
>     $FPLFormatOpt['count'] = array('fn' => 'FPLCount');
>
> Then one could simply use (:pagelist fmt=count ...:) to return the
> number of pages.
>
> Hope this helps!
>
> Pm
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: /pipermail/pmwiki-users/attachments/20070327/06c04ac1/attachment.html 


More information about the pmwiki-users mailing list