vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.5 Add-ons (https://vborg.vbsupport.ru/forumdisplay.php?f=113)
-   -   Average age in forumhome (https://vborg.vbsupport.ru/showthread.php?t=99283)

Lea Verou 10-24-2005 10:00 PM

Average age in forumhome
 
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:
HTML Code:

<span title="<phrase 1="$vboptions[activememberdays]">$vbphrase[within_the_last_x_days]</phrase>">$vbphrase[active_members]: $activemembers</span>
                </if>

Add below:
HTML Code:

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
Code:

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

Quote:

Originally Posted by Loukrhtia
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

Code:

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*


All times are GMT. The time now is 12:16 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01095 seconds
  • Memory Usage 1,734KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_code_printable
  • (2)bbcode_html_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete