Go Back   vb.org Archive > Community Discussions > Modification Requests/Questions (Unpaid)
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 11-17-2008, 10:40 AM
valdet's Avatar
valdet valdet is offline
 
Join Date: Feb 2007
Posts: 505
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default How to build a table from profile fields data?

I am trying to build a custom table from few custom profile fields.

Something like the following sketch:



Few fields would need to be sorted on ASC or DESC order based on user input.

Does anyone has an idea or hints what is the best way to make something like this?
Maybe an example.


Thanks for your time.

Best regards,
Val.
Attached Images
File Type: jpg fields.jpg (45.7 KB, 0 views)
Reply With Quote
  #2  
Old 11-17-2008, 02:36 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

It's just a table on another page? You can start with one of these - How to create your own vBulletin-powered page! (uses vB templates) or [How-To] vBulletin API Basics: Creating Custom Pages & Misc. The fields are just in the database, so a simple query should get them, then just spit them out. Start with getting them outputted, then add in the sort (which would just be a simple switch with the result added to the end of the query as a "ORDER BY..." statement).
Reply With Quote
  #3  
Old 11-18-2008, 12:56 PM
valdet's Avatar
valdet valdet is offline
 
Join Date: Feb 2007
Posts: 505
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Lynne View Post
It's just a table on another page? You can start with one of these - How to create your own vBulletin-powered page! (uses vB templates) or [How-To] vBulletin API Basics: Creating Custom Pages & Misc. The fields are just in the database, so a simple query should get them, then just spit them out. Start with getting them outputted, then add in the sort (which would just be a simple switch with the result added to the end of the query as a "ORDER BY..." statement).
Thanks Lynne,

Actually I am trying to display that table on portal homepage (through vBAdvanced). I've posted the question there too.

I am also trying to use the resources found from this post but didn't have much success so far.


The table I am trying to make is a simple one, I only don't know how to populate the columns underneath it.
I would use this code for column titles

Code:
<thead>
    <tr align="center">
      <td class="thead" width="55%">Name</td>
      <td class="thead" width="15%">Points</td>
      <td class="thead" width="8%">Year</td>
      <td class="thead" width="9%">Weight</td>
      <td class="thead" width="9%">Height</td>
    </tr>
</thead>
Thanks for your time.
Reply With Quote
  #4  
Old 11-18-2008, 01:42 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'm not familiar with vBadvanced at all, so I can't help with any of that. But, the fields you want are in the userfield table. The column 'userid' is the userid, and then the other columns are named 'field1', 'field2', 'field3', etc. So, it should be pretty easy for you to grab that information.
Reply With Quote
  #5  
Old 11-21-2008, 10:32 AM
valdet's Avatar
valdet valdet is offline
 
Join Date: Feb 2007
Posts: 505
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Well after a lot of hard work, I managed to make a plugin which pulled any profile field I selected.

Currently, it is fetching data from two tables: user and userfield

Here is the result



Currently I am sorting these data based only from a single field in my query.
Code:
ORDER by  userfield.field26 DESC





Here's my question:


What I would like to know, is if there is an easier way to make the titles of these columns clickable (highlighted in red in pic), so when you click the titles (Graduation Year, Height, Weight) the system will sort those columns in accordance with that respective field

The picture will explain it better.

I appreciate your time and looking forward to replies.

Val.
Reply With Quote
  #6  
Old 11-21-2008, 02:45 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

What I do on a similar page I wrote, is pass a sort variable. Then I have a switch in my page:
PHP Code:
switch ($_REQUEST["sort"])
    {
        case 
'gyasc':
            
$orderby "ORDER BY fieldx ASC";
            break;
        case 
'gydesc':
            
$orderby "ORDER BY fieldx DESC";
            break;
        case 
'fieldyasc':
            
$orderby "ORDER BY fieldy ASC";
            break;
        case 
'fieldydesc':
            
$orderby "ORDER BY fieldy DESC";
            break;
.........
        default:
            
$orderby "ORDER BY fieldz DESC";
    } 
Then I add that variable to the end of my query:
PHP Code:
        $query "select blah, blah FROM ".$TABLE_PREFIX."thread as thread WHERE blah, blah' and thread.visible = 1 $orderby $limit"
And then just make your titles clickable and pass the sort variable:
HTML Code:
<a href="yourpage.php?sort=gydesc">Graduation Year</a>
Reply With Quote
  #7  
Old 11-23-2008, 02:33 AM
Ted S Ted S is offline
 
Join Date: Dec 2003
Location: SoCal
Posts: 3,954
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

vBulletin has some great functions and code that you can easily rework with any data that will allow ordering up or down as well as searching, multiple pages, etc... I'd suggest you pick apart memberlist.php and look at the structure used there as well as the various code bits and bring the ones you want into your own script. It may take a little work to bring everything over to a script you wrote from scratch but it will give you more functionality down the road and helps insure your code is optimized to some degree.
Reply With Quote
  #8  
Old 12-02-2008, 10:20 AM
valdet's Avatar
valdet valdet is offline
 
Join Date: Feb 2007
Posts: 505
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Lynne, Ted, thanks so much for offering me tremendous assistance. I was able to create what I was aiming to.

Now I'll just have to fiddle around with conditionals so various usergroups see different stats.

Here are the screens along with links to DESC ▼ and ASC ▲ ordering









Regards.
Reply With Quote
  #9  
Old 12-02-2008, 02:31 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Looks good! :up:
Reply With Quote
  #10  
Old 12-03-2008, 07:18 AM
valdet's Avatar
valdet valdet is offline
 
Join Date: Feb 2007
Posts: 505
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks Lynne,

I plan to release this when it is fully finished.

Additionally, could you give a hint how could the sorter links ( ▼ and ▲ ) , or templates involved be loaded with Ajax?

Right now when I click on those links all of the page is reloaded.

Thanks,
Val.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 10:04 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.07766 seconds
  • Memory Usage 2,288KB
  • Queries Executed 12 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (2)bbcode_code
  • (1)bbcode_html
  • (2)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (1)postbit_attachment
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_attachment
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete