[pmwiki-users] Naming-convention, problems with links

H. Fox haganfox at users.sourceforge.net
Fri May 5 09:45:43 CDT 2006


On 5/5/06, Daniel Hofer <daho at borntofly.ch> wrote:
> Hello Hagan
>
> thanks for your help!
>
> I had another idea:
> whats about pagenames like
>   pagename-suffix
>
> the only thing I need is "pagename", that means the {$Name} until hyphen.
>
> But I have no idea how to solve this within config.php.
>
> Can you help me?

Well, I have a script that strips file extensions with this code:

    ext = strrchr($img, '.');
    $img = substr($img, 0, -strlen($ext));

In that script filenames always have extensions but your pagenames
don't always have hyphens, so this modification should work:

   $pagename = ResolvePageName($pagename);
   $name = PageVar($pagename, '$Name');
   $FmtPV['$DayName'] = ($extra = strrchr($name, '-'))
     ? "'".substr($name, 0, -strlen($extra))."'"
     : '';

Roughly speaking this means "if there's at least one hyphen in the
page's name, the {$DayName} page variable will be all characters up to
the last hyphen, otherwise it will be an empty string.

This might be better:

   $pagename = ResolvePageName($pagename);
   $name = PageVar($pagename, '$Name');
   if (strlen($name) >= 8) { $first8 = substr($name, 0, 8); }
   $FmtPV['$DayName'] = (is_numeric(@$first8)) ? "'".$first8."'" : '';

This one translates to "if the first eight characters of this page's
name are numeric, the {$DayName} page variable will be those eight
characters, otherwise it will be an empty string.

Hagan

> Thanks a lot!
>
> Daniel




More information about the pmwiki-users mailing list