vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Modification Requests/Questions (Unpaid) (https://vborg.vbsupport.ru/forumdisplay.php?f=112)
-   -   How to build a table from profile fields data? (https://vborg.vbsupport.ru/showthread.php?t=196527)

valdet 11-17-2008 10:40 AM

How to build a table from profile fields data?
 
1 Attachment(s)
I am trying to build a custom table from few custom profile fields.

Something like the following sketch:

http://img220.imageshack.us/img220/5707/fieldslg2.jpg

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.

Lynne 11-17-2008 02:36 PM

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

valdet 11-18-2008 12:56 PM

Quote:

Originally Posted by Lynne (Post 1667521)
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.

Lynne 11-18-2008 01:42 PM

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.

valdet 11-21-2008 10:32 AM

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

http://img237.imageshack.us/img237/7840/profilesnl3.jpg

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.

Lynne 11-21-2008 02:45 PM

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>

Ted S 11-23-2008 02:33 AM

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.

valdet 12-02-2008 10:20 AM

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


http://img217.imageshack.us/img217/879/37988700ak7.jpg

http://img399.imageshack.us/img399/5329/58039647gj0.jpg

http://img399.imageshack.us/img399/8859/59512713ep9.jpg


Regards.

Lynne 12-02-2008 02:31 PM

Looks good! :up:

valdet 12-03-2008 07:18 AM

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.


All times are GMT. The time now is 01:47 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.01846 seconds
  • Memory Usage 1,749KB
  • 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
  • (1)bbcode_html_printable
  • (2)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)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