[Req] Filter Threads Alphabetically

WascallyWabbit

New Member
I am in the process of converting my phpbb3 forum to vbulletin and there is a nifty little mod for it thatsorts topics alphabetically . It allows you to click on a letter in the forum view and then display the threads beginning with just that letter. It's very much like the same feature in the VB's memberlist.

I have managed to find someone's attempt at it, but the instructions don't make a whole lot of sense to me. I would really appreciate it if someone could either clarify the instructions the guy made, or make something new.

Thanks a lot
 
dark_hunter said:
Can't you look? Lazy?
Well, I have looked as stated in my previous post :P. Seriously, I have been running my site on phpbb3 for over a year now and am not at all familiar with the VB interface.
 
Ok, I found this code by a guy that said it worked. The problem is I get lost where to put things when he goes into this custom page.php and a subsection called alphasearch. If someone could clarify this stuff I would really appreciate it.

Alphabetical Search Menu for your vBulletin page

This tutorial will help you make an alphabetical search menu similar to what we see in memberlist.php

I had been looking for this for quite some time, opened a thread too but no help. Now, after some little programming homework I find it quite easy. Hope few of you find this useful.

1. Assuming you have intermediate knowledge of HTML and PHP.
2. Its hard for me to understand how this is done in memberlist.php. But this is the most easy way.
3. Do follow the comments in code.
4. I am not a coder. Egypt.Com EnForum

Egypt.Com EnForum

1. First, we create a template for our product titled alphamenu and copy this code into it.

Code:
<table class="tborder" cellpadding="6" cellspacing="1" border="0" width="100%" align="center">

<tr align="center">

<td class="alt2" width="3%"><a href="page.php?do=alphasearch&ltr=A">A</a></td>

<td class="alt2" width="3%"><a href="page.php?do=alphasearch&ltr=B">B</a></td>

<td class="alt2" width="3%"><a href="page.php?do=alphasearch&ltr=C">C</a></td>

<td class="alt2" width="3%"><a href="page.php?do=alphasearch&ltr=D">D</a></td>

<td class="alt2" width="3%"><a href="page.php?do=alphasearch&ltr=E">E</a></td>

<td class="alt2" width="3%"><a href="page.php?do=alphasearch&ltr=F">F</a></td>

<td class="alt2" width="3%"><a href="page.php?do=alphasearch&ltr=G">G</a></td>

<td class="alt2" width="3%"><a href="page.php?do=alphasearch&ltr=H">H</a></td>

<td class="alt2" width="3%"><a href="page.php?do=alphasearch&ltr=I">I</a></td>

<td class="alt2" width="3%"><a href="page.php?do=alphasearch&ltr=J">J</a></td>

<td class="alt2" width="3%"><a href="page.php?do=alphasearch&ltr=K">K</a></td>

<td class="alt2" width="3%"><a href="page.php?do=alphasearch&ltr=L">L</a></td>

<td class="alt2" width="3%"><a href="page.php?do=alphasearch&ltr=M">M</a></td>

<td class="alt2" width="3%"><a href="page.php?do=alphasearch&ltr=N">N</a></td>

<td class="alt2" width="3%"><a href="page.php?do=alphasearch&ltr=O">O</a></td>

<td class="alt2" width="3%"><a href="page.php?do=alphasearch&ltr=P">P</a></td>

<td class="alt2" width="3%"><a href="page.php?do=alphasearch&ltr=Q">Q</a></td>

<td class="alt2" width="3%"><a href="page.php?do=alphasearch&ltr=R">R</a></td>

<td class="alt2" width="3%"><a href="page.php?do=alphasearch&ltr=S">S</a></td>

<td class="alt2" width="3%"><a href="page.php?do=alphasearch&ltr=T">T</a></td>

<td class="alt2" width="3%"><a href="page.php?do=alphasearch&ltr=U">U</a></td>

<td class="alt2" width="3%"><a href="page.php?do=alphasearch&ltr=V">V</a></td>

<td class="alt2" width="3%"><a href="page.php?do=alphasearch&ltr=W">W</a></td>

<td class="alt2" width="3%"><a href="page.php?do=alphasearch&ltr=X">X</a></td>

<td class="alt2" width="3%"><a href="page.php?do=alphasearch&ltr=Y">Y</a></td>

<td class="alt2" width="3%"><a href="page.php?do=alphasearch&ltr=Z">Z</a></td>

</tr>
</table>

2. Then in our custom vbulletin page.php, we create a subpage called alphasearch and copy the below code into it. Ofcourse, this would require editing according to your needs, so read the comments carefully.

Code:
//******* ALPHA SEARCH MENU*******
if ($_REQUEST['do'] == 'alphasearch') //Creating sub-page
{
$letter = "-1";
if (isset($_GET['ltr'])) {
  $letter = $_GET['ltr'];}  //Grabbing alphabet from URL.

//****Beginning Page Navigation (Thanks to Raven for this)******//    
    // Default page variables
    $perpage = $vbulletin->input->clean_gpc('r', 'perpage', TYPE_UINT);
    $pagenumber = $vbulletin->input->clean_gpc('r', 'pagenumber', TYPE_UINT);
    // Count all log entries
    $itemcount = $db->query_first("
        SELECT COUNT(`uid`) AS `itemcount`
        FROM `" . TABLE_PREFIX . "mytable` WHERE colname LIKE '" . $letter . "%'"); //Change colname to actual column name in table that you want to search in.
        
if ($itemcount['itemcount'] == 0) { // Show if recordset empty
$emptysearch=true; // With this, you can easily create a condition in the template to show NO ITEMS message
} // Show if recordset empty        
        
   // Make sure all these variables are cool
    sanitize_pageresults($itemcount['itemcount'], $pagenumber, $perpage, 10, 8); //Change 8 to as many records you want to show per page
    // Default lower and upper limit variables
    $limitlower = ($pagenumber - 1) * $perpage + 1;
    $limitupper = $pagenumber * $perpage;
    if ($limitupper > $itemcount['itemcount'])
    {
        // Too many for upper limit
        $limitupper = $itemcount['itemcount'];
        if ($limitlower > $itemcount['itemcount'])
        {
            // Too many for lower limit
            $limitlower = $itemcount['itemcount'] - $perpage;
        }
    }
    if ($limitlower <= 0)
    {
        // Can't have negative or null lower limit
        $limitlower = 1;
    }

eval('$alphamenu .= "' . fetch_template('alphamenu') . '";'); //Use this line of code to show alphamenu in any sub-page you want. Then simply use $alphamenu variable in the associated template.

$query_Searchltr=$db->query_read("SELECT * from " . TABLE_PREFIX . "mytable WHERE colname LIKE '" . $letter . "%' LIMIT " . ($limitlower - 1) . ", $perpage"); //Change colname to the same column name you had set in the above count query

while ($search_result = $db->fetch_array($query_Searchltr))
{
$row_id=$search_result['uid'];
$row_name=$search_result['name'];
$row_class=$search_result['class'];
// and so on...
}
   // Finally construct the page nav
$pagenav = construct_page_nav($pagenumber, $perpage, $itemcount['itemcount'], 'page.php?do=alphasearch' . $vbulletin->session->vars['sessionurl'] . '&ltr=' . $letter);  
//****End Page Navigation******//

$navbits = construct_navbits($navbits);
eval('$navbar = "' . fetch_template('navbar') . '";');
eval('print_output("' . fetch_template('mysearchbits') . '");'); //The main output prints on mysearchbits template, so create it and use variables defined within the while loop above for results
$db->free_result($query_Searchltr);
}
//*******END ALPHA SEARCH MENU*******
Now, as said earlier in comments, simply use this line in any sub-page and put $alphamenu in the associated template. This would show the menu.

Code:
eval('$alphamenu .= "' . fetch_template('alphamenu') . '";');
 
The Admin over at vbplusme.com and I have been working on this code and we have made some pretty good progress. It is not completed yet as we have yet to make a result screem, but it's getting close. If anyone wants to see the progress so far go here
 
Back
Top