1
cesser
A way to display last login date in a user list?
  • 2004/12/9 5:15

  • cesser

  • Just popping in

  • Posts: 26

  • Since: 2004/3/21


Hi everyone

I've been working with XOOPS off and on for the past year, but only recently have really gotten into it and I think it's great.

I'm currently working on a new website and I wanted to know if it is possible to generate a block similar to the New Members system block, but have it display the last login time for each user instead of the join date. I've been pulling my hair out for the last couple hours trying to possibly get this to work, but no luck. I tried taking the New Users template html code and putting it into a custom block in order to manipulate it, but when I do that, the output is just a bunch of garbled code. Not sure what I am doing wrong. Maybe I don't understand the concept of the template process. I have already cloned the default template set. How do I then clone, say, the New Users block so that I can change it how I wish? Assuming that is accomplished, what variable would I call in the html code in order to display last login time? I thought it would be either last_login or lastlogin, but neither of those seem to be it.

Forgive my ignorance, just starting out here for the most part. I would really appreciate any help on this one.

Thanks in advance.

2
brash
Re: A way to display last login date in a user list?
  • 2004/12/9 6:33

  • brash

  • Friend of XOOPS

  • Posts: 2206

  • Since: 2003/4/10


<{$user_lastlogin}> ?

3
cesser
Re: A way to display last login date in a user list?
  • 2004/12/9 15:02

  • cesser

  • Just popping in

  • Posts: 26

  • Since: 2004/3/21


I must still be missing something here.

Here is the default code for the system_block_newusers.html template:

Quote:
<table cellspacing="1" class="outer">
<{foreach item=user from=$block.users}>
<tr class="<{cycle values="even,odd"}>" valign="middle">
<td align="center">
<{if $user.avatar != ""}>
<img src="<{$user.avatar}>" alt="" width="32" /><br />
<{/if}>
<a href="<{$xoops_url}>/userinfo.php?uid=<{$user.id}>"><{$user.name}></a>
</td>
<td align="center"><{$user.joindate}></td>
</tr>
<{/foreach}>
</table>



Shouldn't I just be able to substitute <{$user_lastlogin}> in the code above in place of <{$user.joindate}> as in the example below:

Quote:
<table cellspacing="1" class="outer">
<{foreach item=user from=$block.users}>
<tr class="<{cycle values="even,odd"}>" valign="middle">
<td align="center">
<{if $user.avatar != ""}>
<img src="<{$user.avatar}>" alt="" width="32" /><br />
<{/if}>
<a href="<{$xoops_url}>/userinfo.php?uid=<{$user.id}>"><{$user.name}></a>
</td>
<td align="center"><{$user_lastlogin}></td>
</tr>
<{/foreach}>
</table>



Whenever I try to do that, only the username is returned, not the last login time.

What am I doing wrong?

Sorry for the "rookieness" and thanks again.

4
Dave_L
Re: A way to display last login date in a user list?
  • 2004/12/9 15:34

  • Dave_L

  • XOOPS is my life!

  • Posts: 2277

  • Since: 2003/11/7


The content for the template system_block_newusers.html is provided by the function b_system_newmembers_show in the file modules/system/blocks/system_blocks.php. (I determined that by looking at the $modversion['blocks'] section of the file modules/system/xoops_version.php.

The function b_system_newmembers_show doesn't define a template variable containing the last-login time, so you would have to add that:

$block['users'][$i]['id'] = $newmembers[$i]->getVar('uid');
$block['users'][$i]['name'] = $newmembers[$i]->getVar('uname');
$block['users'][$i]['joindate'] = formatTimestamp($newmembers[$i]->getVar('user_regdate'), 's');
[
color=ff0000]$block['users'][$i]['last_login'] = formatTimestamp($newmembers[$i]->getVar('last_login'), 's');[/color]


Then you could use <{$user.last_login}> in the template system_block_newusers.html.

5
cesser
Re: A way to display last login date in a user list?
  • 2004/12/9 15:54

  • cesser

  • Just popping in

  • Posts: 26

  • Since: 2004/3/21


That worked Dave_L!

Thank you very much for the help!

6
Dave_L
Re: A way to display last login date in a user list?
  • 2004/12/9 16:04

  • Dave_L

  • XOOPS is my life!

  • Posts: 2277

  • Since: 2003/11/7


You're welcome.

Login

Who's Online

124 user(s) are online (85 user(s) are browsing Support Forums)


Members: 0


Guests: 124


more...

Donat-O-Meter

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

Latest GitHub Commits