Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2007-05-15 11:13:53
- beechy
- Member
- Registered: 2006-03-02
- Posts: 92
avatar with the <txp:author /> tag
What would be the best way of displaying an avatar image linked to the <txp:author /> tag.
I basically want to display an image of the author next to their name at the top of all articles.
I asume it would be something like
if <txp:author /> is joe blogs then
<img src=”<txp:site_url />images/joeblogs.jpg” width=“59” height=“60”>
but as you can see I have no idea how to implement or code this. Any help would be appreciated.
Thanks in advance
Offline
Re: avatar with the <txp:author /> tag
The is where to store the information about the author avatar, txp_user table havent the information!
I dont see how you handle that easily!
maybe using a custom_field where you store the id of image avatar, but then the avatar is attached to an article and not to author!
Offline
Re: avatar with the <txp:author /> tag
If you add the authors yourself (as opposed to them self-registering) and don’t mind uploading images without using TXP, then it can be as simple as this:
<img src="<txp:site_url />images/<txp:php>echo urlencode(author(array()));</txp:php>.jpg" width="59" height="60">
or, if you prefer to use the login name instead of the real name:
<img src="<txp:site_url />images/<txp:php>echo urlencode($GLOBALS['thisarticle']['authorid']);</txp:php>.jpg" width="59" height="60">
Last edited by ruud (2007-05-15 11:43:17)
Offline
#4 2007-05-15 11:46:45
- beechy
- Member
- Registered: 2006-03-02
- Posts: 92
Re: avatar with the <txp:author /> tag
wicked
thanks ruud I take it i just call the jpgs that I upload exactly the same as the author name
Offline
#5 2007-05-15 12:02:00
- beechy
- Member
- Registered: 2006-03-02
- Posts: 92
Re: avatar with the <txp:author /> tag
Works perfect you just upload the images as Joe+Bloggs.jpg
This is probably getting too complicated but – would their also so be a way to display the authors title next to the image.
i.e
Joe+Bloggs.jpg
By Joe Blogs
Head of marketing
I only intend to have 5 authors
at the moment it looks like -
<img src=”<txp:site_url />images/<txp:php>echo urlencode(author(array()));</txp:php>.jpg” width=“59” height=“60”>
<ul id=“employee”>
<li>By <txp:author /></li>
<li>Head of marketing</li>
</ul>
Thanks again
Offline
Re: avatar with the <txp:author /> tag
Yes, just name them exactly the same as either the (real) author name or the login name, depending on which of the two approaches you pick.
Btw, the approach suggested by Dragondz is possible as well. You’d have to create a section called ‘authors’ or ‘profiles’ in which each each author can put an article with his/her own profile. In one of the custom fields or perhaps more appropriately in the article_image field, the ID of the image for that author can be stored. The image could then be displayed like this (using section ‘profiles’ and the ‘article image’ field):
<txp:php>echo image(array('id'=> safe_field('Image', 'textpattern', "Section='profiles' and AuthorID='".doSlash($GLOBALS['thisarticle']['authorid'])."'"))));</txp:php>
Using an URL instead of an ID in the article_image field is possible as well, but as long as you’re using TXP, might as well use all the built in stuff to do the work for you.
Image placement can be influenced by setting an appropriate style (CSS). Perhaps add “float: right;” to the style for the image?
Last edited by ruud (2007-05-15 12:20:05)
Offline
#7 2007-05-21 20:05:21
- alexandra
- Member
- From: Cologne, Germany
- Registered: 2004-04-02
- Posts: 1,370
Re: avatar with the <txp:author /> tag
The easiest way is rss_author_info
Offline
Re: avatar with the <txp:author /> tag
Elegant, interesting Ruud!
Just a question : how to get the caption image with some PHP raw?
Tks for your answer.
Regards,
Patrick.
Github | CodePen | Codier | Simplr theme | Wait Me: a maintenance theme | [\a mi.ni.ma]: a “Low Tech” simple Blog theme.
Offline