View Full Version : Average age in forumhome
Lea Verou
10-24-2005, 10:00 PM
This is a modification I really wanted for my forum and I am posting it cause I thought that others may find it useful as well. However, I only had the idea as Xenon helped my really much with the query (My SQL knowledge is very basic and this is why this hack isn't supported, I wish I could support it but I don't have the knowledge to do so).
Thanks also to tamarian for fixing the issue with the table prefix. :)
Instructions
1. Import the attached XML file. It's a plugin, not a product :)
2. Edit template FORUMHOME:
Find:
<span title="<phrase 1="$vboptions[activememberdays]">$vbphrase[within_the_last_x_days]</phrase>">$vbphrase[active_members]: $activemembers</span>
</if> Add below:
Average Age: $avg_age
You're done! :)
If you liked this and you are using it, don't forget to click INSTALL!
If you want less or more than 2 decimals at the average then:
In the plugin manager click Avg Age in order to edit the plugin code.
Find DAYOFYEAR(NOW())) / 365), 2) and change the 2 in green to the number of decimals you like. :)
Andreas
10-25-2005, 02:16 PM
If you make the plugin use TABLE_PREFIX it will work on every installation, without needing to edit the Plugin :)
Lea Verou
10-25-2005, 02:23 PM
I know but for some reason that gives a database error! :(
Andreas
10-25-2005, 02:33 PM
Just replace vb3_ with " . TABLE_PREFIX . " and it should work fine.
Lea Verou
10-25-2005, 02:37 PM
That's EXACTLY what I did. It doesn't. Really strange...
tamarian
10-25-2005, 04:42 PM
That's EXACTLY what I did. It doesn't. Really strange...
Make sure when you add TABLE_PREFIX that you remove vb3_ :)
Lea Verou
10-25-2005, 04:48 PM
I did! I'll test the attached plugin and if it causes no db errors in my test forum I'll update the attachment :)
Thanks :)
edit: Yep, no database errors. I still can't figure out what I was doing wrong, lol. :p :) Thanks a lot tamarian! :D
Boots
10-25-2005, 04:57 PM
I'd change the query to something like
SELECT ROUND(AVG(YEAR(NOW()) - YEAR(birthday_search) - (DAYOFYEAR(birthday_search) - DAYOFYEAR(NOW())) / 365), 2) AS avgage WHERE YEAR(birthday_search) > 1950
replace 1950 with any cutoff date... on my forum where I was an old phpbb forum I have some birthdays in there of 1900 for some reason so that addition makes the query more accurate.
Extreme John
10-25-2005, 05:32 PM
This took two seconds to add, excellent hack!
Moncal
10-25-2005, 05:59 PM
*clicks installed*
Snake
10-26-2005, 08:25 AM
Installed!
Lea Verou
10-26-2005, 09:37 AM
Installed!
If you liked this and you are using it, don't forget to click INSTALL!
:);)
weaver
10-26-2005, 10:04 AM
How would you integrate this with vbadvanced? I found the template to insert it into but it's not showing a value for age.
Lea Verou
10-29-2005, 10:16 AM
How would you integrate this with vbadvanced? I found the template to insert it into but it's not showing a value for age.
Woops sorry I took so long to respond, I didn't notice your message!
What do you mean "integrate it with vbadvanced"? You want it to show in the stats block?
Also, the most common reasons for it not showing a value for age:
1. You haven't done the template change correctly
2. The plugin isn't enabled
3. If you have the very first version of the hack, you haven't entered the database perfix correctly (if that's the case you would get a db error as well)
Do you get any errors or the number just doesn't show?
Julie
12-24-2005, 11:14 PM
Hm, funny little thing this :D Thanks!
*installs*
Lea Verou
12-24-2005, 11:23 PM
Thank you :)
What is funnier is the way I came up with it! :p
Some people (a very annoying competitor as well) that had only seen a little of my forum were saying that it has a very low level of average age which I knew was not true. So I put that in the forumhome and when they saw average age 29 they shut their mouths :D
Julie
12-24-2005, 11:40 PM
Thank you :)
What is funnier is the way I came up with it! :p
Some people (a very annoying competitor as well) that had only seen a little of my forum were saying that it has a very low level of average age which I knew was not true. So I put that in the forumhome and when they saw average age 29 they shut their mouths :D
Haha, wicked! Well, great ideas often come from simple things like that!
El Barto
02-19-2006, 07:20 PM
This didnt work in my forum.
Edit; it works fine, thanxs! :)
Lea Verou
02-19-2006, 07:25 PM
What does it show?
El Barto
02-19-2006, 07:45 PM
What does it show?
I`m sorry, but I did something wrong.
Lea Verou
02-19-2006, 07:53 PM
did you solve the problem?
El Barto
02-19-2006, 08:16 PM
Yes, i did at first place "Average Age: $avg_age" above if.
alfaowner
02-19-2006, 09:58 PM
works well, thanks
yowen
02-23-2006, 01:03 AM
It's not displaying anything for me...
this is what I see: "Average Age: "
I upgraded from 3.0.0 RC4 and my forumhome template does show up (in admincp home) as one of the templates that has been updated. But I cant find anything in there that would cause this code not to work, I just put it in the code right after the member count
btw. This is on a password protected test forum, not the one listed in my profile.
PJSkiboy
02-23-2006, 09:35 AM
Excellent little addition.
I have one forum member (oldest guy on the forums) always saying everyone is so young, yada yada yada....
Now he can eat some humble pie. :D
Thanks a ton.
Lea Verou
02-23-2006, 02:29 PM
Is the plugin enabled yowen?
yowen
02-25-2006, 04:55 PM
yes it is.
Pagandream
04-02-2006, 07:51 AM
Hi,
thx for this hack? But one question, how does it calculate the age? In my forum 50 % doesn't have fill out her age, coz it not necessary for getting registered. Does it only use those with an age in the profile or does it use all member?
For example you have 4 Members, all are 20 years old but only 3 have fill out their age, so will it calculate 60:3 = 20 or 60:4=15
Sorry for my bad english
Lea Verou
04-02-2006, 07:53 AM
I calculates from all members that have entered a date :)
dutchbb
04-30-2006, 06:31 PM
Hm, funny little thing this :D Thanks!
*installs*
Unfortunatly a funny little thing that adds 1 query, and imho, that's not really worth it.
Lea Verou
05-01-2006, 09:23 AM
Unfortunatly a funny little thing that adds 1 query, and imho, that's not really worth it.
Then don't install it.
In what particular way can your comment be considered "constructive"?
Boofo
05-01-2006, 12:43 PM
Then don't install it.
In what particular way can your comment be considered "constructive"?
Don't worry, Michelle, I'll install this. If he can come up with another way to get this info without a query, then he'll be doing magic. ;)
dutchbb
05-28-2006, 01:14 PM
Then don't install it.
I didn't
In what particular way can your comment be considered "constructive"?
Because people should know this.
I didn't mean to be offensive or anything.
Protonus
09-08-2006, 09:36 PM
Wanted to let ya'll know this works in 3.6. However I didn't like where it displayed the age, thought it was kinda of weird, makes it look like it's implying it's the age of the members currently signed in.
Instead, I wanted it next to the member total in the navbar. See here for instructions on how to do this, I think it looks a lot better:
http://www.vbstyles.com/forum/showthread.php?t=3155
adwade
10-23-2006, 01:40 AM
See here for instructions...
For the benefit of those who don't have a vbstyles login...
Yes, it in template "navbar".
Please try it like this (works for me):
open template "navbar" and search for:
$vbphrase[active_members]: $activemembers</span></if></div>Modify this line that it looks like:
$vbphrase[active_members]: $activemembers</if>, Average Age: $avg_age</span></div>Daniel
:D Great to know this works with vB3.6 :D and FWIW, Miko (http://www.vbstyles.com) makes GREAT Skins for vB!
The Coon
04-15-2009, 09:37 AM
Great ... still works with 3.8.2! THX!
alfaowner
05-28-2009, 01:01 AM
Great ... still works with 3.8.2! THX!
Agreed, thanks!
The Coon
11-15-2009, 07:30 PM
Unfortunately it don`t works with vBulletin 4.
Could please someone take a look on this cool Plug-in?
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.