On Thursday 08 March 2007 16:34, Jon Haupt wrote: > On 2/4/07, Jon Haupt <[EMAIL PROTECTED]> wrote: > > I'm trying to create custom page variables that show the wiki title > > and the page title with plusses instead of spaces. In other words, > > instead of {$Titlespaced}, I want {$Titleplussed}, with the result > > showing PmWiki/DocumentationIndex as Documentation+Index. > > > > The wiki title part I found to be pretty easy, and I accomplished it > > with this code: > > > > # PlusIt converts all spaces in a string into plusses. > > function PlusIt($text) { > > $text = preg_replace('/\s+/', '+', $text); > > return $text; > > } > > # page variable > > $FmtPV['$WikiTitlePlussed'] = 'PlusIt($GLOBALS["WikiTitle"])'; > > > > However, {$TitlePlussed} is more difficult, or at least I haven't been > > able to figure it out. Can I do something similar in order to put the > > contents of {$Titlespaced} through my PlusIt function? Also, could I > > have accomplished the above in an easier way? > > > > Thanks, > > > > Jon > > I never received a response to this message, so I thought I'd resend > it. I still haven't been able to figure out why it's harder to do > $TitlePlussed than $WikiTitlePlussed. If I can get this solved, I can > release a useful social bookmarking links recipe. Thanks, >
I am not sure if you can access the title variable this way, but you can have a function that will work even for pagelists and any other case, like this: Markup('fmtplus', '>textvar:',"/\\(:fmtplus(.*?):\\)/ie","FmtPlus(\$pagename, PSS('$1'))"); function FmtPlus($pagename, $what){return str_replace(" ","+",trim($what));} (this is in config.php) Then, in the page you write: (:fmtplus This is a test:) will output This+is+a+test Or in pagelists: (:fmtplus {=$Title}:) Or even this: (:title (:fmtplus This is a test:):) Or [[http://google.com/search?q=(:fmtplus My page title:) | Search Google]] (for the latter you should probably use urlencode instead of str_replace). Have fun, Petko _______________________________________________ pmwiki-users mailing list pmwiki-users@pmichaud.com http://www.pmichaud.com/mailman/listinfo/pmwiki-users