vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Modification Requests/Questions (Unpaid) (https://vborg.vbsupport.ru/forumdisplay.php?f=112)
-   -   Show custom profile field on page. (https://vborg.vbsupport.ru/showthread.php?t=185573)

soundboy 07-17-2008 08:01 AM

Show custom profile field on page.
 
Ok..

It was possible in phpbb3.. and im not sure in vbulletin.. but i want to display 10 random entries from a custom profile field..

My members enter a url into a custom profile field and i want to dispaly 10 random entries from different users on my forum index..

If this is possible :)
Thanks in advance:)

RLShare 07-17-2008 11:53 AM

You could use a mysql statement like this...(I think)

Code:

"select fieldNUMBER from ".TABLE_PREFIX."userfield order by rand() limit 10"
Change NUMBER to the actual field number.

psylenced 07-17-2008 12:37 PM

You wouldnt want to run that query per post. Each page load would hit the db 10-20 times per page per user.

RLShare 07-17-2008 01:04 PM

What does that have to do with the question? He wants to show it once on his forumhome not per post.

soundboy 07-18-2008 03:00 AM

Quote:

Originally Posted by RLShare (Post 1577669)
You could use a mysql statement like this...(I think)

Code:

"select fieldNUMBER from ".TABLE_PREFIX."userfield order by rand() limit 10"
Change NUMBER to the actual field number.

thanks, how would i implement this? Sorry, im only new to vbulletin (im a phpbb coder but wanting to code vb) ;)

RLShare 07-18-2008 03:28 AM

You would use the vb database manager to run the query and gather the info like so....


PHP Code:

$fields=$vbulletin->db->query_read("select fieldNumber from ".TABLE_PREFIX."userfield order by rand() limit 10"); 

Then loop through the data and structure it however you want using the $vbulletin->db->fetch_array() function...
ex....
PHP Code:

while($field $vbulletin->db->fetch_array($fields)){
///Process data...



You would want to put this in a plugin that hooks the proper location, more then likely the forumhome_start hook location since you want to display it on the forumhome template... Usually format and place all the data into a variable and then edit the template of which your plugin is hooking and add that variable. VB also has Template hooks where you can add data to pre-defined variables that will get displayed in the templates without ever editing a template.

RLShare 07-18-2008 03:33 AM

1 Attachment(s)
Here is a sample plugin that draws in a profile field and places it in a table so you can get an idea of how to do it...Edit the plugin and change the field6 in the query to the one that corresponds to your forum before you import the plugin.

You would then need to edit your forumHome template and find $navbar then place $pb_fields right under it.

soundboy 07-18-2008 03:35 AM

:o i still dont understand..

so do i put the info in my file (index.php) ?
i need further steps, sorry :(

EDIT: i will try that plugin you made :D thanks

--------------- Added [DATE]1216356491[/DATE] at [TIME]1216356491[/TIME] ---------------

ok.. i edited the plugin and ran it..
also edited my template..
and im getting no result showing up?

RLShare 07-18-2008 03:58 AM

All that means is there is an extra '<' somewhere in the code that there should not be. Its not in the plugin unless you edited the html in the plugin.

soundboy 07-18-2008 04:01 AM

ok! i got it but.. its on the forum homepage..
I am running vbdrupal, how would i be able to get it on that page?

also its displaying empty tables.. how can i make it so it doesnt show null fields? or empty fields?
Many thanks mate :D

RLShare 07-18-2008 04:03 AM

ahh just seen you edited your post... I forgot to mention that you will also need to change the field6 in the 2 spots that this shows up....'$field['field6']'

soundboy 07-18-2008 04:07 AM

yup i changed that :)
its working but i wish to show it on my vbdrupal page? also its showing empty fields, how can i make it only show ones that are filled in?

RLShare 07-18-2008 04:08 AM

change the query to this but edit the field numbers again


PHP Code:

 "SELECT field6
FROM "
.TABLE_PREFIX."userfield
WHERE field6 != ''
ORDER BY rand( )
LIMIT 10 " 

As far as the VBDrupal page, I have never messed with drupal before.

soundboy 07-18-2008 04:16 AM

Thankyou VERY much!
I changed the hook to global_start :)
+rep

--------------- Added [DATE]1216358345[/DATE] at [TIME]1216358345[/TIME] ---------------

oh.. sorry again.. but i have another field i want to display..

Ive set up the url which is field7, and i wish to display field5 like..

<a href="field7">field5</a>

Thanks for your help again!

RLShare 07-18-2008 04:54 AM

Change the query to
PHP Code:

"SELECT field5, field7
FROM "
.TABLE_PREFIX."userfield
WHERE field5 != '' AND field7 !=''
ORDER BY rand( )
LIMIT 10" 


And then change this part of the plug-in...
Code:

<a href=\''.$field['field6'].'\'>'.$field['field6'].'</a>
To..
Code:

<a href=\''.$field['field7'].'\'>'.$field['field5'].'</a>

soundboy 07-18-2008 04:55 AM

many thanks mate :)


All times are GMT. The time now is 05:49 PM.

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.01158 seconds
  • Memory Usage 1,753KB
  • 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
  • (4)bbcode_code_printable
  • (4)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (16)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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete