Snippet integration in views

FuXXz - May 1, 2009 - 18:25
Project:User Stats
Version:6.x-1.x-dev
Component:Code
Category:support request
Priority:normal
Assigned:Unassigned
Status:closed
Description

Hello,

i use this snippet for integration the online/offline status in nodes / profiles

Online:

<?php
print (user_stats_get_stats('online', $node->uid) ? 'yes' : 'no');
?>

Now, i want to integrate it in a view. I use a view template but i need still the correct snippet for integrate!

Can you help me?

#1

Liam McDermott - May 1, 2009 - 20:58
Category:feature request» support request
Assigned to:FuXXz» Anonymous
Status:active» fixed

If you just want to display online/offline in a yes/no format, add the 'Is online' field to your view. Then, when the settings form for the field appears, set the 'Output format:' to 'Yes/No'.

Hope I'm correctly interpreting the question. :)

#2

FuXXz - May 5, 2009 - 20:26

strictly speaking i want to use this snippet because i need a picture for display the status!

<img alt="User is <?php print (user_stats_get_stats('online', $node->uid) ? 'online' : 'offline'); ?>" src="<?php print base_path() . path_to_theme() .'/'. (user_stats_get_stats('online', $node->uid) ? 'online.png' : 'offline.png'); ?>" />

#3

Liam McDermott - May 8, 2009 - 20:36

I see what you're trying to do now, thanks for clarifying. :)

This is something I'd like to deal with better in future versions of User Stats, but for now, you'd have to theme the View you need the online indicator to appear in.

A Google search for views 2 theming turned up a few interesting results, this article on theming Views 2 looks quite promising, for example.

(by the way, this isn't an 'omg! why didn't you just Google it?' snub against you, I'm aware that you wouldn't have known what to look for! :) )

#4

System Message - May 22, 2009 - 20:40
Status:fixed» closed

Automatically closed -- issue fixed for 2 weeks with no activity.

#5

com2 - November 27, 2009 - 12:27

What you want to use is Views Custom Field. This allows you to include a Custom Field with PHP code. You just have to replace $node with $data and it should work.

 
 

Drupal is a registered trademark of Dries Buytaert.