1
alain01
Re-Design the PM templates - Need smarty help
  • 2020/4/29 12:45

  • alain01

  • Just can't stay away

  • Posts: 536

  • Since: 2003/6/20


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

2
alain01
Re: Re-Design the PM templates - Need smarty help
  • 2020/4/29 13:21

  • alain01

  • Just can't stay away

  • Posts: 536

  • Since: 2003/6/20


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 !

3
luciorota
Re: Re-Design the PM templates - Need smarty help
  • 2020/4/29 14:10

  • luciorota

  • Module Developer

  • Posts: 216

  • Since: 2007/4/20


Hi Alain01

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

4
luciorota
Re: Re-Design the PM templates - Need smarty help
  • 2020/4/29 14:26

  • luciorota

  • Module Developer

  • Posts: 216

  • Since: 2007/4/20


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!

5
alain01
Re: Re-Design the PM templates - Need smarty help
  • 2020/4/29 15:09

  • alain01

  • Just can't stay away

  • Posts: 536

  • Since: 2003/6/20


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 ...

6
Mamba
Re: Re-Design the PM templates - Need smarty help
  • 2020/4/29 15:37

  • Mamba

  • Moderator

  • Posts: 11409

  • Since: 2004/4/23


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.11 | Docs | Modules | Bugs

7
alain01
Re: Re-Design the PM templates - Need smarty help
  • 2020/4/29 15:45

  • alain01

  • Just can't stay away

  • Posts: 536

  • Since: 2003/6/20


@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.

8
luciorota
Re: Re-Design the PM templates - Need smarty help
  • 2020/4/29 15:55

  • luciorota

  • Module Developer

  • Posts: 216

  • Since: 2007/4/20


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}>

9
alain01
Re: Re-Design the PM templates - Need smarty help
  • 2020/4/29 16:01

  • alain01

  • Just can't stay away

  • Posts: 536

  • Since: 2003/6/20


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

10
Mamba
Re: Re-Design the PM templates - Need smarty help
  • 2020/4/29 20:05

  • Mamba

  • Moderator

  • Posts: 11409

  • Since: 2004/4/23


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.11 | Docs | Modules | Bugs

Login

Who's Online

336 user(s) are online (93 user(s) are browsing Support Forums)


Members: 0


Guests: 336


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