vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Best method of grabbing user's threads, categorised? (https://vborg.vbsupport.ru/showthread.php?t=108864)

Oblivion Knight 02-25-2006 03:06 PM

Best method of grabbing user's threads, categorised?
 
I'm working on a little something to manage the content of my site via vBadvanced CMPS, without it being displayed publically on the forum home..

However, for the "Content Editor", I'm struggling to come up with a way to pull a user's threads AND have them categorised per forum basis. I imagine that I'll have to use an array, or a foreach loop of some kind for this - but I'm not that great with either..


Here's my current file:
Code:

<?php

// Lazy, but it works..
$userid = $vbulletin->userinfo['userid'];
$forumids = "2,6";

$prevarts = $db->query_read("SELECT threadid, title, forumid FROM " . TABLE_PREFIX . "thread WHERE postuserid = $userid AND forumid IN ($forumids) ORDER BY dateline DESC");

while ($titles = $db->fetch_array($prevarts))
{
        $tit = $titles['title'];
        $tid = $titles['threadid'];
        $fid = $titles['forumid'];

        eval('$articles .= "' . fetch_template('adv_portal_contenteditorbit') . '";');
}
$db->free_result($titles);

eval('$home[$mods[\'modid\']][\'content\'] = "' . fetch_template('adv_portal_contenteditor') . '";');

?>

While I could attempt to "borrow" some of vB's code for the 'Find all threads started by X' feature, I don't need any permission checking code because the tool is only accessible to staff anyway - and I'd rather try and understand how to code more efficiently (also, I dare say that the search.php file is a jungle of code to break down and navigate through for exactly what I require)..

Marco van Herwaarden 02-25-2006 03:22 PM

Change "ORDER BY dateline DESC" to "ORDER BY forumid, dateline DESC" in your query.

Oblivion Knight 02-25-2006 03:48 PM

Heh, perhaps I should have explained a little better.. ;)

I'm displaying the output in a select box, but I want to categorise the <option>s with <optgroup>s.
So effectively..


[high]BEFORE:[/high]

Article 3
Article 2
Article 1


[high]AFTER:[/high]

Category A
Article 3
Article 1
Category B
Article 2


Although you're right, I will need to add that to the query.! :p



[high]---EDIT---[/high]
I've done it by adding a count for every forumid for now..

It's kinda dirty though, so if anyone has a better way - I'd love to hear it.! ;)


All times are GMT. The time now is 04:37 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.02017 seconds
  • Memory Usage 1,713KB
  • 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
  • (1)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (3)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