[pmwiki-users] Truncate PageTitle

Peter Bowers pbowers at pobox.com
Mon Aug 20 07:11:16 CDT 2012

On Mon, Aug 20, 2012 at 1:30 PM, Brian Tibbels
<brian.tibbels at clickmarlow.co.uk> wrote:
> I need to truncate a page title for side bar presentation
> (:title Language - Full Page Title:)
> I need the text after " - ".

If the "Language -" part is a constant length across all pages then
standard markup expressions with the {(substr ...)} would handle it.

I'm guessing, however, that the length of the "Language -" part
changes.  In that case you could use the {(reg_replace ...)} features
of MarkupExpressionPlus
(http://www.pmwiki.org/wiki/Cookbook/MarkupExprPlus) or the {(sed
...)} features of WikiSh (http://www.pmwiki.org/wiki/Cookbook/WikiSh).

Or you could come up with your own PV that hardcodes the deletion of
the text up to the dash:

$FmtPV['$TitleShort'] = 'array_pop(explode(" - ",
FmtPageTitle(@$page["title"], $name, 1)))';

(There are probably more elegant ways to accomplish this last but this
should give you an idea where to start.)


More information about the pmwiki-users mailing list