xoops forums

alain01

Quite a regular
Posted on: 4/29 12:45
alain01
alain01 (Show more)
Quite a regular
Posts: 388
Since: 2003/6/20
#1

Re-Design the PM templates - Need smarty help

Hi,
i want to redesign the PM templates,
- pm_readpmsg.tpl
- pm_viewpmsg.tpl
- pm_pmlite.tpl

I know there are yet the 2 first files in BT4 overloaded,
but i want to make a real responsive design in BT4.

I need a smarty variable which is avalaible in the readpmsg.tpl (defined in readpmsg.php file) in the viewpmsg.tpl file :

<{if ( $poster->getVar("user_avatar") != "")}>
                    <
img src="<{$xoops_url}>/uploads/<{$poster->getVar('user_avatar')}>" alt="<{$poster->getVar('uname')}>" class="img-responsive img-rounded img-thumbnail">
                <{/if}>


i need to use the avatar postername.
i know how to use
<img src="<{$xoops_url}>/uploads/<{$member_info.user_avatar}>" height="22px" class="align-top">

but it's not the good code, $member_info is for the member who is connected...

In the viewpmsg.tpl file, the smarty <{$message.posteruid}> is known.
So i want to get the avatar for this user

alain01

Quite a regular
Posted on: 4/29 13:21
alain01
alain01 (Show more)
Quite a regular
Posts: 388
Since: 2003/6/20
#2

Re: Re-Design the PM templates - Need smarty help

I tried :
<img src="<{$xoops_url}>/uploads/<{$message.posteruid->getVar('user_avatar')}>" alt="<{$message.posteruid->getVar('uname')}>" class="img-responsive img-rounded img-thumbnail">


but it doesn't work !

luciorota

Module Developer
Posted on: 4/29 14:10
luciorota
luciorota (Show more)
Module Developer
Posts: 204
Since: 2007/4/20
#3

Re: Re-Design the PM templates - Need smarty help

Hi Alain01

Is becouse $message.posteruid is the poster id and not a poster object

luciorota

Module Developer
Posted on: 4/29 14:26
luciorota
luciorota (Show more)
Module Developer
Posts: 204
Since: 2007/4/20
#4

Re: Re-Design the PM templates - Need smarty help

To get user_avatar this way is a dirty way.. but it could run!

Insert in "viewpmsg.tpl" file
into the <{foreach item=message from=$messages}> loop
this Smarty code

<{php}>
    
$user_handler xoops_getHandler('user');
    
$posterObj $user_handler->get($GLOBALS['message']['posteruid']);
    echo 
$posterObj->getVar('user_avatar');
<{/
php}>


Good luck!

alain01

Quite a regular
Posted on: 4/29 15:09
alain01
alain01 (Show more)
Quite a regular
Posts: 388
Since: 2003/6/20
#5

Re: Re-Design the PM templates - Need smarty help

Thank you luciorota,
i'm so close...

<img src="<{$xoops_url}>/uploads/<{php}>
    
$user_handler = xoops_getHandler('user');
    
$posterObj = $user_handler->get($GLOBALS['message']['posteruid']);
    echo 
$posterObj->getVar('user_avatar');
<{/php}>" 
class="img-responsive img-rounded img-thumbnail">


It gives me an avatar image, but always same avatar...
I'm in the <foreach >...

Mamba

Moderator
Posted on: 4/29 15:37
Mamba
Mamba (Show more)
Moderator
Posts: 10944
Since: 2004/4/23
#6

Re: Re-Design the PM templates - Need smarty help

Take a look at Yogurt - LioMJ leveraged work done by Alfred on his eProfile, and now Yogurt pretty much is able to replace the Profile using Preloads.

Maybe you could use Preloads to do something similar with PM?
Support XOOPS => DONATE
Use 2.5.10 | Docs | Modules | Bugs

alain01

Quite a regular
Posted on: 4/29 15:45
alain01
alain01 (Show more)
Quite a regular
Posts: 388
Since: 2003/6/20
#7

Re: Re-Design the PM templates - Need smarty help

@Mamba
?
No, i dont want to modify the php code of the PM module,
i just want to add overloaded files for webmasters which use PM module.

luciorota

Module Developer
Posted on: 4/29 15:55
luciorota
luciorota (Show more)
Module Developer
Posts: 204
Since: 2007/4/20
#8

Re: Re-Design the PM templates - Need smarty help

Trry this
More than dirty

<{if ($message.postername != "")}>
<{* 
what if user does not exist? *}>
<{
assign var="tempPosteruid" value=$message.posteruid}>
<
img src="<{$xoops_url}>/uploads/<{php}>
    
$user_handler = xoops_getHandler('user');
    if(
$posterObj = $user_handler->get($this->get_template_vars('tempPosteruid'))) {
        echo 
$posterObj->getVar('user_avatar');
    }
    <{/php}>" 
class="img-responsive img-rounded img-thumbnail">
<{/if}>

alain01

Quite a regular
Posted on: 4/29 16:01
alain01
alain01 (Show more)
Quite a regular
Posts: 388
Since: 2003/6/20
#9

Re: Re-Design the PM templates - Need smarty help

YESSSSSSSS !!!
Done !!!
Thank you,
I dont know why now it works with your new code but it works fine !

Mamba

Moderator
Posted on: 4/29 20:05
Mamba
Mamba (Show more)
Moderator
Posts: 10944
Since: 2004/4/23
#10

Re: Re-Design the PM templates - Need smarty help

Alain said: Quote:
No, i dont want to modify the php code of the PM module,

No, you use Preloads in your module...
But it's great that Lucio was able to find a solution for you.
Support XOOPS => DONATE
Use 2.5.10 | Docs | Modules | Bugs