Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2010-02-16 22:41:10

hicks
Member
From: Portland, OR, USA (ex-UK)
Registered: 2009-05-08
Posts: 106
Website

Author's initials only

Hello,

Is there a way to show just the article’s author’s initials, like some print magazines have? For example, if the author was Dennis Quaid, the output would be DQ. You probably didn’t need an example.

Thanks!

Hicks.

Offline

#2 2010-02-16 23:35:52

jsoo
Plugin Author
From: NC, USA
Registered: 2004-11-15
Posts: 1,793
Website

Re: Author's initials only

<txp:php>foreach(explode(' ',author(array())) as $n)echo substr($n,0,1);</txp:php>

Code is topiary

Offline

#3 2010-02-16 23:43:38

hicks
Member
From: Portland, OR, USA (ex-UK)
Registered: 2009-05-08
Posts: 106
Website

Re: Author's initials only

Perfect. Thank you.

Offline

#4 2010-02-17 11:02:49

jsoo
Plugin Author
From: NC, USA
Registered: 2004-11-15
Posts: 1,793
Website

Re: Author's initials only

Note to self: don’t forget you can access strings using array notation. So

<txp:php>foreach ( explode(' ', author(array())) as $n ) echo $n[0];</txp:php>

is a cleaner alternative.


Code is topiary

Offline

#5 2010-02-17 22:46:24

hicks
Member
From: Portland, OR, USA (ex-UK)
Registered: 2009-05-08
Posts: 106
Website

Re: Author's initials only

Even more perfecter. Ta.

Offline

Board footer

Powered by FluxBB