11
kymseen
Re: Adding avatars to news items??
  • 2006/9/11 13:26

  • kymseen

  • Just popping in

  • Posts: 23

  • Since: 2006/9/11


Hello, I am also looking to add user(poster) avaters on blog contents.
I want to add a little avatar next to posted by:****.

trabis or anyone with knowledge, please post up a tutorial, please!
any help would be appreciated!!

12
kymseen
Re: Adding avatars to news items??
  • 2006/9/15 7:09

  • kymseen

  • Just popping in

  • Posts: 23

  • Since: 2006/9/11


anyone???

I did a little digging myself.
and I found that


in newsbythisauthor.php

row: 129
----------------------
$xoopsTpl->assign('user_avatarurl', XOOPS_URL.'/uploads/'.$thisuser->getVar('user_avatar'));
----------------------
is where they get the user avatar and

they call it out with

<{$user_avatarurl}>

in news_by_author.html


I wanted to show the avatar on the article page and I looked up

article.php
-----------------------
$story['poster'] = $article->uname();
if ( $story['poster'] ) {
$story['posterid'] = $article->uid();
$story['poster'] = ''.$story['poster'].'';
} else {
$story['poster'] = '';
$story['posterid'] = 0;
if(getmoduleoption('displayname')!=3) {
$story['poster'] = $xoopsConfig['anonymous'];
}
}
-------------------------

I know I need to hack this section but need help...

Anyone???

I know I'm close...

sorry for the bad english

13
trabis
Re: Adding avatars to news items??
  • 2006/9/15 8:38

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


Hymseen
I´m a newbie in Xoops, php and sql so I did it the same way as you... researching. I don´t know if this is the best or optimized or convencional way to do do it but here it goes:

I "messed" in 3 files:

article.php (to get the avatar on each article)
class/class.newsstory.php (to get the avatar in front page)
templates/news_item.html (to display the avatar)

In article.php around line 270 and below "$xoopsTpl->assign('mail_link',
'mailto:?subject='.sprintf(_NW_INTARTICLE,$xoopsConfig['sitename']).'&body='.sprintf(_NW_INTARTFOUND, $xoopsConfig['sitename']).': '.XOOPS_URL.'/modules/news/article.php?storyid='.$article->storyid());"
I pasted this code:
global $xoopsDB;
$result $article->uid();
$result2 $xoopsDB->query("SELECT user_avatar FROM ".$xoopsDB->prefix("users")." where uid='$result'");
$result3 $xoopsDB->fetchArray($result2);    
$story['avatar_url'] =  XOOPS_URL.'/uploads/'.$result3['user_avatar'];


In class/class.newsstory.php around line 600 (in the function "function prepare2show($filescount)") below "$story['posttime'] = formatTimestamp($story['posttimestamp'],getmoduleoption('dateformat'));" i´ve pasted this code (similar but not equal):
global $xoopsDB;
$result $this->uid();
$result2 $xoopsDB->query("SELECT user_avatar FROM ".$xoopsDB->prefix("users")." where uid='$result'");
$result3 $xoopsDB->fetchArray($result2);    
$story['avatar_url'] =  XOOPS_URL.'/uploads/'.$result3['user_avatar'];


In news_item.html you have to paste this in where you want the avatar to be displayed:
<img src="<{$story.avatar_url}>">

I used this way

<
div class="itemBody"><img src="<{$story.avatar_url}>" 
align="right"/><class="itemText"><{$story.text}>p>

so it replace the topic image!


One thing to have in mind: Some themes have their own news_item.html so if your theme as it you have do do your changes there!
Clear your templates and refresh the news module.

Tip:You can also get a default avatar for your users by modifing uploads/blank.gif

Well, I think that´s all.
Let me know if you where sucessful!
Thanks!

14
kymseen
Re: Adding avatars to news items??
  • 2006/9/17 14:36

  • kymseen

  • Just popping in

  • Posts: 23

  • Since: 2006/9/11


thanks for the tutorial trabis!!

however I am currently using news1.15 and couldn't find the following...

in class/class.newsstory.php near line 600 (in the function "function prepare2show($filescount)")

"$story['posttime'] = formatTimestamp($story['posttimestamp'],getmoduleoption('dateformat')); "


trabis, are you using news1.44???

I wonder how I can do it in the news1.15 module...

(by the way, the reason I am using news1.15 is I have a problem with the recent news blocks dissapearing with news1.44)see this topic

thank you

15
trabis
Re: Adding avatars to news items??
  • 2006/9/17 15:15

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


Yes , I´m using news 1.44. In news 1.15 there is no such funtion. All it´s done in index.php. I did not try it but I think it´s simple. In index.php search for this:
$scount count($sarray);
for ( 
$i 0$i $scount$i++ ) {
    
$story = array();
    
$story['id'] = $sarray[$i]->storyid();
    
$story['poster'] = $sarray[$i]->uname();
    if ( 
$story['poster'] != false ) {
        
$story['poster'] = ".XOOPS_URL."/userinfo.php?uid=".$sarray[$i]->uid()."'>".$story['poster']."";
    } else {
        
$story['poster'] = $xoopsConfig['anonymous'];
    }


You see that? "$array[$i]->uid()" !!!! Guess it´s the Id of the poster so below the above code paste this:

global $xoopsDB;
$result $array[i$]->uid();
$result2 $xoopsDB->query("SELECT user_avatar FROM ".$xoopsDB->prefix("users")." where uid='$result'");
$result3 $xoopsDB->fetchArray($result2);    
$story['avatar_url'] =  XOOPS_URL.'/uploads/'.$result3['user_avatar'];


And forget class.newsstory.php

Try it.

I also add in my articles 5 links to articles of the same author! Look in my site Luso-Poemas

The issue of the missing blocks never afeted me. I don´t use them. But i´ll take a look. Bye.
Sorry for the bad english!

16
kymseen
Re: Adding avatars to news items??
  • 2006/9/23 18:04

  • kymseen

  • Just popping in

  • Posts: 23

  • Since: 2006/9/11


trabis, still confused...
is this what you mean???


$sarray = NewsStory::getAllPublished($xoopsOption['storynum'], $start, $xoopsOption['storytopic']);

$scount = count($sarray);
for ( $i = 0; $i < $scount; $i++ ) {
$story = array();
$story['id'] = $sarray[$i]->storyid();
$story['poster'] = $sarray[$i]->uname();
if ( $story['poster'] != false ) {
$story['poster'] = "".$story['poster']."";
} else {
$story['poster'] = $xoopsConfig['anonymous'];
}

global $xoopsDB;
$result = $array[i$]->uid();
$result2 = $xoopsDB->query("SELECT user_avatar FROM ".$xoopsDB->prefix("users")." where uid='$result'");
$result3 = $xoopsDB->fetchArray($result2);
$story['avatar_url'] = XOOPS_URL.'/uploads/'.$result3['user_avatar'];



I'm having trouble with these hacks and the results are not showing, I have tried updating the modules, and so.

any clue??

17
trabis
Re: Adding avatars to news items??
  • 2006/9/23 21:35

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


Yes, that is correct. Even if you have done it wrong it should apear a red cross indicating there was no image in the news item.
So I guess the error might be in news_item.html.
See if your thme as it´s own "news_item.html". Mine for example has it and i had to make my changes there.
If it doesn´t then show me what you did there, ok?

Login

Who's Online

433 user(s) are online (375 user(s) are browsing Support Forums)


Members: 0


Guests: 433


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits