On 7/16/07, noskule <[EMAIL PROTECTED]> wrote: > hi list > I have some trouble to get this php code to runn properly, could please > someone giving me a hand? > > I try to get the basename of a page: > > SomeGroup.SomeName-Topic-12 -> SomeGroup.SomeName > > GLOBAL $TopicBaseName,$CommentBaseName; > > $name = PageVar($pagename, '$Name'); > $backnametopic = explode('-Topic-',$name); > $backnametopic = $backnametopic[0]; > $FmtPV['$TopicBaseName'] = $backnametopic; > > this work like expected. > > > SomeGroup.SomeName-Topic-12-Comment-3 -> SomeGroup.SomeName-Topic-12 > > $name = PageVar($pagename, '$Name'); > $backnamecomment = explode('-Comment-',$name); > $backnamecomment = $backnamecomment[0]; > $FmtPV['$CommentBaseName'] = $backnamecomment; > > this don't work and gives me: -12
I think this would work both places: $backname = preg_replace("/-Topic-.*\$/", '', $name); in other words $name = PageVar($pagename, '$Name'); $backname = preg_replace("/-Topic-.*\$/", '', $name); $FmtPV['$BackName'] = "'$backname'"; or maybe $name = PageVar($pagename, '$Name'); if (preg_match("/-Topic-.*\$/", $name)) { $backname = preg_replace("/-Topic-.*\$/", '', $name); $FmtPV['$BackName'] = "'$backname'"; } makes {$BackName} always return the page's name up to the first "-" in "-Topic-". Hagan _______________________________________________ pmwiki-users mailing list pmwiki-users@pmichaud.com http://www.pmichaud.com/mailman/listinfo/pmwiki-users