[pmwiki-users] Truncate PageTitle

Brian Tibbels brian.tibbels at clickmarlow.co.uk
Mon Aug 20 08:18:33 CDT 2012


Thank you Peter. Unfortunately the "Language" part is variable in length. I
suppose I'm looking for the equivalent of a "strpos" in expressions.



On 20 August 2012 13:11, Peter Bowers <pbowers at pobox.com> wrote:

> 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.)
>
> -Peter
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.pmichaud.com/pipermail/pmwiki-users/attachments/20120820/b0a76a63/attachment.html>


More information about the pmwiki-users mailing list