PDA

View Full Version : Weird request - Pull Thread titles


lasto
04-04-2005, 01:44 AM
ok have this forum and i want any thread made in that section to have its title (the name of the thread) pulled to a seperate page so i can see every title in alphabet mode with a link back to the orginal thread.

Any one up for this ?

cinq
04-04-2005, 02:15 AM
SELECT threadid, title FROM thread WHERE forumid = X ORDER BY title ASC


All you need, really :)

lasto
04-04-2005, 02:30 AM
from a novice point of view - how cinq

How do i ake this run in a php file or whatever ?

twoseven
04-04-2005, 03:16 AM
from the vbulletin manual appendix 4

$results = $DB_site->query("
SELECT field_one, field_two
FROM " . TABLE_PREFIX . "table AS table
WHERE field_one IN(3,4,5)
AND field_two <> ''
AND field_three = 'something'
ORDER BY field_one
");

so with the modified query it owuld be something like

$results = $DB_site->query("
SELECT threadid, title FROM " . TABLE_PREFIX . " thread WHERE forumid = X ORDER BY title ASC
");

hope that helps

lasto
04-04-2005, 03:20 AM
sort of helps but it dont help me in displaying the results

i make a php file with your query above as follows :

<?php
$results = $DB_site->query("
SELECT threadid, title FROM " . TABLE_PREFIX . " thread WHERE forumid = 213 ORDER BY title ASC
");


?>

Fatal error: Call to a member function on a non-object in /home2/ on line 2

i need to know how i can call this info back in a seperate page so i can view the entire list as that querie aint working

cinq
04-04-2005, 03:48 AM
Your custom page ( assuming in your forum dir ) should look something like this :


<?php
require_once('./global.php');

$results = $DB_site->query("
SELECT threadid, title FROM " . TABLE_PREFIX . " thread WHERE forumid = 213 ORDER BY title ASC
");

while ($row = $DB_site->fetch_Array($results))
{
$id = $row['threadid'];
$title = $row['title'];
eval('$threadbits .= "' . fetch_template('mypage_threadbits') . '";');
}

eval('print_output("' . fetch_template('mypage_main') . '");');
?>


Now create 2 templates: mypage_main and mypage_threadbits.
The mypage_main will be the main page layout, and where you want the thread titles to show, put a $threadbits in the mypage_main template.

The mypage_threadbits is the template in which the titles are shown.
Use $title to display the title and link to the thread by using $id as the threadid.

lasto
04-04-2005, 09:56 AM
works perect so far - cant get an active link back to the real thread though
got the threads showing on a page but the names aitn clickable and ive followed the code above exactly as you have put it m8 ?

here is what shows :

Eastern Front Map 21306

just need the actual text to be clickable to go back to the actual thread

Deaths
04-04-2005, 10:01 AM
You can just add
<a href="showthread.php?t$id">$title</a>

To the template :)

lasto
04-04-2005, 10:06 AM
working now thanks a lot :) (thanks death and cinq)

one last thing - at moment in cinq code its set to show the maps from one section only (forumid 213)

how can i get it to say show from more than one section as altoogether i need it for 4 ids

Deaths
04-04-2005, 11:01 AM
Replace this code:

$results = $DB_site->query("
SELECT threadid, title FROM " . TABLE_PREFIX . " thread WHERE forumid = 213 ORDER BY title ASC
");

with:

$results = $DB_site->query("
SELECT threadid, title FROM " . TABLE_PREFIX . " thread WHERE (forumid=XXX OR forumid=XXX OR forumid=XXX OR forumid=XXX) ORDER BY title ASC
");

You can add more OR's, or remove a couple, it's up to you :)
Dont forget to replace the XXX's though.

lasto
04-04-2005, 11:10 AM
really chuffed with this code :0

one final thing is there a way for me to get it to display at the top of the page how many threads it has pulled altogether ??

so it shows like this

Maps on server : (number)

then displays results ?

Deaths
04-04-2005, 11:29 AM
Add this to the file:
$mapcount = $DB_site->query_first("SELECT count(threadid) AS maps FROM " . TABLE_PREFIX . "thread WHERE (forumid=XXX OR forumid=XXX OR forumid=XXX OR forumid=XXX)");

$nummaps = $mapcount['maps']

Now you can use $nummaps in your template.

lasto
04-04-2005, 12:54 PM
adding that code gives me a parse error

TyleR
04-04-2005, 01:04 PM
he just missed a semi-colon at the end :p

$mapcount = $DB_site->query_first("SELECT count(threadid) AS maps FROM " . TABLE_PREFIX . "thread WHERE (forumid=XXX OR forumid=XXX OR forumid=XXX OR forumid=XXX)");

$nummaps = $mapcount['maps'];

lasto
04-04-2005, 01:21 PM
:)


perfect - shows 148 now excellant

now its pulled the correct data i need is there anyway for me to make it use my boards colors or style as at moment its just text on a white background

Deaths
04-04-2005, 01:22 PM
Ah, my bad.

lasto
04-04-2005, 01:48 PM
read my last post PLZ

Deaths
04-04-2005, 02:02 PM
Sorry, only just read it.

Hold on, I'll give you the code.

Make this the main thread:

$stylevar[htmldoctype]
<html dir="$stylevar[textdirection]" lang="$stylevar[languagecode]">
<head>
<title>$vboptions[bbtitle]</title>
$headinclude
</head>
<body>
$header


$navbar

<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center">
<tr>
<td class="tcat">SOME TITLE</td>
</tr>
<tr>
$BIT_VARIABLE
</tr>

</table>

$footer
</body>
</html>


Now, create this as bit template:

<td class="alt1"><a href="showthread.php?t$id">$title</a>
</td>

lasto
04-04-2005, 02:14 PM
cheers m8 for your help

Deaths
04-04-2005, 02:21 PM
Did it work?

lasto
04-04-2005, 02:29 PM
sort of

its useing the colors of my board but the box for the title appears at the bottom while the thread titles appear at the top

Deaths
04-04-2005, 02:34 PM
Ni, by some title I ment the title which you want to give it, like "Total threads in forum XXX" ;)

lasto
04-04-2005, 02:49 PM
yeah i know that :)

i gave it a title but what im saying is with the code you provided the title should appear in a box which it does,but it appears right at the bottom of the page and the titles from the threads appear before it.

No worries though i can quite easy fix this bit - cheers again death.

Deaths
04-04-2005, 03:14 PM
Ok :).

If you need any other help, just gimme a shout.

lasto
04-04-2005, 03:25 PM
will do m8 cheers

ok everything i have asked for has been completed and is working really well but id like to expand upon this if someone wants to help.

So far it now pulls the threads titles and displays them in alphabet mode but id like the display to be made in boxes if possible to make it look more presentable.

At moment it just shows the titles so how about a seperate column to show the author of the post ?

lasto
04-05-2005, 04:15 PM
is there anyway i can have the code tydied up - look in the post above for a pic of the display i see.I would like it to be in a sort of box or mouseover from when i go from one link to the next if possible.Anything but plain text on a white screen :)

Deaths
04-05-2005, 04:23 PM
Add this above your query:

$alt=1;

Now, INSIDE the foreach tag, add this:

$alt++;
if ($alt>2) $alt=1;


Example:


foreach (XXX as YYY)
{
eval....
$alt++;
if ($alt>2) $alt=1;
}


Now, in the bit template, to your td tag, add:
class="alt$alt"
So, like this:

<td class="alt$alt">.....


That should color up the links' backgrounds :)

lasto
04-07-2005, 02:42 AM
ok another thing - is there a way to get it to pull the date of the thread title with it so can see when it was made and very last thing to actually pull the size of the attachment so when viewing all the maps on a seperate page it will show the following info :

mapname1 05/05 127KB

etc

lasto
05-24-2006, 04:23 PM
Fatal error: Call to a member function on a non-object in /home/custom/vb3/maps.php on line 4

does the above query work on vb3.5.4 as ive just upgraded the board and this no longer works.

Here is the code in my php file

<?php
require_once('./global.php');

$results = $DB_site->query("
SELECT threadid, title FROM " . TABLE_PREFIX . " thread WHERE (forumid=82 OR forumid=83) ORDER BY title ASC
");

while ($row = $DB_site->fetch_Array($results))
{
$id = $row['threadid'];
$title = $row['title'];
eval('$threadbits .= "' . fetch_template('mypage_threadbits') . '";');
}
$mapcount = $DB_site->query_first("SELECT count(threadid) AS maps FROM " . TABLE_PREFIX . "thread WHERE (orumid=82

OR forumid=83)");

$nummaps = $mapcount['maps'];
eval('print_output("' . fetch_template('mypage_main') . '");');
?>