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 _______________________________________________ pmwiki-users mailing list pmwiki-users@pmichaud.com http://www.pmichaud.com/mailman/listinfo/pmwiki-users