Hi all,
I have a big problem (i think for you it´s small one ;-) ).
I want to have a "Who´s online block" i know there are alot of snippets and modules out there but I´m looking for a special function.
I try to get it look this way :
(10 last logged in users/or online users)
Username (coloured pink if profile_gender = female and light blue if profile_gender = male)
I would also like to have a small icon in front of the username
if profile_gender = male show website.com/drupal/files/male.jpg 25x25px
if profile_gender = female show website.com/drupal/files/female.jpg 25x25px
I´m very sorry but I have two other stupid questions (but I don´t get it on my own):
How can i print this 10 users into 2 columns (5on the right and 5 on the left) ?
And how can I have a border around this whole thing...
I´m very sorry but I don´t get it to work since days/weeks and now I have to annoy you with this newbie questions.
Thanks in advance,
best regards,
Maik
Comments
share t trick to all
i don know how to do it..post it if u r successful
i can just tel u ,u need to modify the code that is meant for who's online block in the htdocs
I had the idea myself but i
I had the idea myself but i don´t know how to do it. :D
Hmmm...
It will take me months to figure it out :D
ATTENTION Newbies!!
Skip to the bottom of the post to see the final version.
If you want to see the process we went through to get the final version, continue reading.
I dunno how, but I can hammer it out
This seems like something that we could figure out together. Let's start with a good base: the Custom "Who's Online" Block. Which version of Drupal are you using?
Assuming that profile_gender is the way it's stored in the DB, we could get the gender out by modifying the original user's query:
and add profile_gender into the SELECT statement. It would now look like this:
As for changing the color of the names, there's a couple of ways to do it.
Since I'm still trying to understand the theme functions, I can't help you with exactly how to override them. I can tell you what's getting called where...
This line:
$output .= theme('user_list', $items, t('Online users'));calls theme_user_list in modules/user.module.There's a function call made to theme_username and theme_item_list which are both in includes/theme.inc.
Hopefully this helps you get closer to solving what you're trying to do.
Thank you for the great
Thank you for the great answer. I´m using Drupal 5.x .
This helps me alot... I´m going to try some things... and will leave you message about my hopefully successfull tries ^^
Best regards,
Maik
P.S: If anybody has some good snippets, please let me know...
What I got until now is just
What I got until now is just that...just the ouput of the online users:
I had an idea (sorry for the syntax.... ;-) ) I don´t know if it´s possible to code something like this...may be this can help you?!
please
Pleaseee help me :( I´m getting mad
=-=
getting mad doesnt help anyone, nor does bumping more then one post of the exact same question. see: http://drupal.org/node/148200
You may want to seek out someone in the paid drupal forum for this customization. This customization is not that minimal, IMHO.
You're mad ... and I'm busy. C'est la vie.
This was taking longer than I thought to build. What you are trying to do is not a simple task. As I said before I don't know how to do this, I'm learning as I go. I do apologize for not responding in a timely manner.
<rant>I check this forum when I have free time. I had higher priority things that needed to be done, because I am paid to do them. Keep in mind, you are using free software. You get what you pay for. Re-read the point that starts "With Volunteer Support..." on the Tips for posting to drupal forums. If you needed immediate support, you should have tried other methods, like going in IRC channels or paying someone (like VeryMisunderstood already said).
Please understand, I'm not trying to insult or berate you, I'm just putting things in perspective.</rant>
There are a couple of ways to do this, and I was trying to figure out the more efficient way. The problem is getting the data in that
profile_genderfield. I didn't know that it wasn't stored in the{users}table. So the$users = db_query(...that we had won't work. We need to look at other wasy to do this.One way would be to load all the info for every user that's online, but that would waste alot of time since we only need one profile field. Instead we need to join that profile field to the user data. So change the
$users = db_query(...to look like this:Now we actually have access to the profile_gender field. Change the code below
$total_users = ...to look like this:I know there's a better way to do the color change by overriding the theme_username function that I mentioned in the last post, but I lack the time to pursue it.
Thank you coreb...great work
Thank you coreb...great work :-)
<so-sorry>I didn´t wanted you to become rant. I said I become mad because I didn´t solved this problem on my own. Not because i had to wait for an answer.
I´m very sorry if you felt affected (i hope it´s the right word...my english is not perfect).
I´m very thankfull for every help that i get, I try to help other users myself (most times I´m just not good enough ;-) )
</so-sorry>I tried the code. I found a mistake in the line:
This was easy to solve
Inside this everything seems to be ok:
But inside the big block seems to be the failure, i tried out the following:
I get the error:
Parse error: syntax error, unexpected T_IF in /www/htdocs/*******/includes/common.inc(1342) : eval()'d code on line 20
so it seems to be in this line:
while ($max_users-- && $account = db_fetch_object($users)) {
Again: I´m very sorry :-(
=-=
I believe $max_users = needs to be set to some number.
$max_users = 25Isn´t this solved in this
Isn´t this solved in this line?
=-=
ahhh, yes, you are probably correct.
$max_users =variable_get('user_block_max_list_count', 10);should probably be:
$max_users = variable_get('user_block_max_list_count', 10);and
should probably be:
missing ;
yes.
$style = "color: ";needs the;on the end. I can't blame that error on moving the code from my code editor to the text box on the page.I'm not mad.
I am not mad. I obviously misunderstood you. That is the danger of using only text as a form of communication, it is very easy to interpret things the wrong way.
Don't worry, if I tried to speak your native language, you would not be able to understand me at all.
I´m glad that you´re not
I´m glad that you´re not mad :-)
Big thanks also to : VeryMisunderstood :-) :-)
I have an other error:
Parse error: syntax error, unexpected $end in /www/htdocs/w007ae56/includes/common.inc(1342) : eval()'d code on line 36
solved with
in line 36 ;-)
But there is something strange... in my profile I´m "male". But my name is displayed pink?!
And female is displayed blue...ok normally this is a simple problem...i changed it this way:
But there is something else:
It looks like this :
Online users
Test
Online users
Test
Maik
You can see this here:
Blast!
Confession time: I didn't test this code out, since I don't have a working test site right now.
The strange colors are because I forgot to add the rest of the condition to that. Change it to look like this:
The code worked exactly like it was written, but it was not written correct. It was looking at your gender and seeing that it matched "M". With
strcasecmp(), that returns a 0. But without that== 0, the statement reads asif (0), which is false.Oddly enough
strcasecmp(), returns >0 when the left string is greater than the right string. Or in your case:M > F. Since it returned something that wasn't 0, the statement reads asif (1), which is true. It's funny that it accidentally did the opposite of what I was trying to do.As for your second error, make sure that you didn't copy/paste the code into the text box twice. I'm blocked by a firewall from seeing the picture, but that's my first guess why you see duplicates.
Ok, I have to say; for not
Ok,
I have to say; for not testing the code it´s great ^^
Ok the colorproblem is solved ;-) . By the way "pink" is working.
I´ve putted it again into another textbox(block).
Still the same problem:
Online users
Maik
Online users
Maik
Test
The strange thing is , the user I´m logged in with is always inside the first 'online users'.
That means, when I´m logging in as 'test' it looks like this:
Online users
Test
Online users
Test
Maik
This is the code I´m using:
misplaced }
should be
The
$outputline is getting processed for every user that's online (which is 2), when it should only run once.Thank you very much...this
Thank you very much...
this is working perfectly (tested with 2 users).
With this, I think 80% of my problem is solved.
Now it should not be very hard to implement a little icon for male/female. I will try to put it into the script.
I´ve sent you an email, would be great if you would reply to this. So I can invite you to my website, when everything is working :-)
You´ve saved my evening. And tomorrow evening and so on ^^.
EDIT:
I thought it will work when i do this:
But I will have to think about this again *rofl* :D
Best regards,
Maik
CSS does it better
I had forgotten about the images you wanted. This is one of those cases where CSS would be better for this. So let's revise my code a little. First, you're going to adapt this so that instead of putting in the actual colors, we'll put the users into a class. Here's a quick refresher of the old code
Now, the changed version:
Now the code on the line
$items[] = l($account->name, 'user/'. $object->uid, array('title' => t('View user profile.'), 'style' => $style));You should replace 'style' with 'class':
$items[] = l($account->name, 'user/'. $object->uid, array('title' => t('View user profile.'), 'class' => $class));The final thing is to go into the theme you're using (which, I believe, is garland) and add some special CSS to the style.css file. I don't know exactly what needs to be added, but here's what can start you off.
I don't know if the CSS code is right, I'm adapting it from here. This is starting to get to the area I'm not so familiar with, but here's some reading that may help you:
http://www.pooliestudios.com/projects/iconize/
http://developer.mozilla.org/en/docs/CSS:Getting_Started:Content
Hopefully someone else w/ more knowledge in this area can chime in soon.
Looks good, currently I´m
Looks good,
currently I´m at work. I will try this code afterwards.
I think I can create this css.
Sorry wasn´t online yesterday any more...I was fallin´asleep in front of my PC ^^
I will post my tries ;-)
Ok I´ve tested it. It´s
Ok I´ve tested it.
It´s working, but it´s working like the standard "who´s online" module.
So, no different colors at all ;-)
Another thing I´m wondering about is this; it looks like this:
°name1
°name2
°name3
why is that ° in front of the names?
Is it because it´s a list?
subscribing
subscribing
tested this but not working
Hi,
it´s me again.
Ok I tested this but it´s not really working.
I made a mistake but I don´t know where it is?
This is the script:
And this is what I added to the style.css :
=-=
per the css originally given to you, should be:
notice the . in a.girluser and a.boyuser
tried this one: a.boyuser
tried this one:
still the same problem ?!
That´s strange
=-=
You've altered the above code section as well. there should be no a in boyuser or girluser in that code.
you also did not follow coreb's instruction with this line:
$items[] = l($account->name, 'user/'. $object->uid, array('title' => t('View user profile.'), 'style' => $style));in this comment : http://drupal.org/node/147374#comment-237726
you have to that line to read:
$items[] = l($account->name, 'user/'. $object->uid, array('title' => t('View user profile.'), 'class' => $class));I highly suggest you, re copy the code given to you by coreb, and replace what you've changed. Then re read the beginning of this thread, specifically coreb's comments.
Thank you very much.But as
Thank you very much.
But as you can see in my previous post, I´ve followed his instructions:
;-)
Thanks it´s working. Thats great.
I have this:
° pic Name
° pic Name
This : ° belongs to block in the css file right? Because it´s a list or am i on a wrong way?
=-=
they are bullets.
using bullets as a search term : brought me these threads: http://drupal.org/search/node/bullets
This comment : http://drupal.org/node/132205#comment-216372
on this thread: http://drupal.org/node/132205
seems to answer your question, using css to remove the bullets.
share the steps to create the who's online block
hi msolt...
glad that 80% of u'r problem is solved....
it would be very nice of you if you post the steps once you've achieved what you wanted.That way newbies like me would find very useful...
please can you put all the steps to achieve your online block
Thank you
Full Version
Hi,
thank you again Coreb & Miss ;-)
This is the Version for
Drupal 5.x
I don´t know if it will work with other Drupal deployments:
Ok do the following steps and everything should work fine:
1.You need the profile field gender.
Goto: Administer->User management->Profiles
Add new field : "list selection" insert a category you want, insert a title.
Form name must be
profile_gender
to work properly with the following steps. If you use an other form name you have to change it also in the script.
Select options should be "male" and "female" without the " " .
Save the field !
2. Goto: Administer->Blocks-> Add Block
Insert a description.
Insert the following code as body.
Set input format to php.
Save the block !
3. Open your style.css (you can find it for example here: domain.com/drupal/themes/garland/style.css)
insert the following code to it:
upload it to where you got it from ;-)
4. Create 2 images in this case female_p.gif and male_p.gif.
The pictures shouldn´t be bigger than 15x15px to look good.
Upload the pictures into your garland directory.
5. Goto Administer->Blocks
Now activate the block.
For example inside the left sidebar.
6. Done ! Everything should work now.
I hope I didn´t forgot something, if it´s not working please let me know.
Please let me (us) know if everything works fine. If there are any mistakes inside the "tutorial" I´ll correct them later.
Best regards,
Maik
P.S: Please excuse my poor english. I hope you understand the steps :-)
I´ve found a little bug
I´ve found a little bug inside this script.
Ok. I try to explain this bug.
When you embed this script into your site, you can see who´s online. Normally when you click on a name inside this list the profile of the specific user gets opened. But not in this script. It always opens YOUR profile.
I try to figure out, why this happens. If anybody got an good idea. Please post it.
Thanks
Ok,I think I´ve found the
Ok,
I think I´ve found the error:
I need to get the userid behind the
'user/'....Tried this...but it´s not working
Thanks for your post
Thanks msolt...
This'll be very helpful for newbies...
I hope so.The problem is
I hope so.
The problem is that there is one, little bug. I´ll try to fix (maybe someone knows how to fix it).
When it´s done I´ll change the script above ;-)
Best regards,
Maik
Congratulations on solving
Congratulations on solving this. There were alot more bugs than I thought.
I have a fix for the bug you found. Looking at the code you last posted:
Change it to:
I copy/pasted that code from somewhere else, but forgot to update to change the variable name from $object to $account.
I've found another "bug", although I'm not sure this piece of code get executed. It depends on the way your site is setup.
should be
Updated php
Great work again coreb...
thank you very much, if u will need help please let me know...I will do my best, to help YOU!
For all who want to use this snippet, here´s the updated Version:
show user pictures
how can i show the user pictures next to the users name?
I am trying to do something
I am trying to do something similar.
But I want to keep the standard drupal "who's online" block that says
There are currently 2 users and 0 guests online.
Online users
* testuser-female
* testuser-male
* is the default icon (that comes with the theme i am using)
All I want is for the female/male users to have different icons from the default icon (the default icon still needs to be used for those that do not enter a gender). I am using the profile with profile_gender set to male or female. This all sounds very simple but I don't know where to find the "who's online" php code and also haven't the faintest idea what code to put in there (would snippets from the codes posted on here work, I don't need the colors of the users changed). Anyone know if this can be done?? any help would be grateful. thanks
there is a code in the forum.Search it
hi ,
I've seen the code snippet in the forum.All i remember is te period in which it wa posted.It was between May 15 th and june 15 th.
try your luck
all the best