try another color scheme:


Go Back   TECH6.0 > Web Design/Development and SEO > Internet Forum Softwares > vBulletin


Need completed Alphabetical Search Menu code

This is a discussion on Need completed Alphabetical Search Menu code within the vBulletin section, part of the Internet Forum Softwares category; Hello Webwizzy. Here is another mystery I am trying to solve. I think you posted a mod on vb .org ...

Reply
 
LinkBack (1) Thread Tools Display Modes
  1 links from elsewhere to this Post. Click to view. #1  
Old 30-03-2009, 08:29 AM
vbplusme's Avatar

Learner
 
Name: Michael
Join Date: Sep 2008
Location: United States
Posts: 2
vbplusme is on a distinguished road
Send a message via Yahoo to vbplusme Send a message via Skype™ to vbplusme
Default Need completed Alphabetical Search Menu code

Hello Webwizzy.

Here is another mystery I am trying to solve. I think you posted a mod on vb.org called :

Alphabetical Search Menu.

It appears to be missing a few steps like the one to create the file page.php.

Do you have the complete MOD stashed anywhere that I could look at how you finished it?

I am thinking that I am suppose to create a custom page called page.php and add your php code to the bottom of it but the instructions on vb.org are missing that piece.

I think its a template, a plug and a custom page. Does that make sense to you?

TIA for any help you might have with this one.

kindest regards, Michael.

I really like this site. You are doing a really fine job with it.
Reply With Quote
  #2  
Old 30-03-2009, 10:36 AM
No Avatar

Learner
 
Join Date: Mar 2009
Posts: 5
wascallywabbit is on a distinguished road
Default

I'm in need of that too. I have the template and plugin created, but the page.php is giving me fits.

Here is my page.php code so far if it helps anyone:
PHP Code:
<?php

// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);

// #################### DEFINE IMPORTANT CONSTANTS #######################
define('NO_REGISTER_GLOBALS'1);
define('THIS_SCRIPT''page'); // change this depending on your filename
define('CSRF_PROTECTION'true);

// ################### PRE-CACHE TEMPLATES AND DATA ######################
// get special phrase groups
$phrasegroups = array(

);

// get special data templates from the datastore
$specialtemplates = array(
    
);

// pre-cache templates used by all actions
$globaltemplates = array(
    
'alphamenu',
);

// pre-cache templates used by specific actions
$actiontemplates = array(

);

// ######################### REQUIRE BACK-END ############################
require_once('./global.php');

// #######################################################################
// ######################## START MAIN SCRIPT ############################
// #######################################################################

//******* 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(`threadid`) AS `itemcount`
        FROM `" 
TABLE_PREFIX "thread` WHERE title 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$perpage108); //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 "thread WHERE title 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'] . '&amp;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*******
?>

Last edited by wascallywabbit; 30-03-2009 at 10:40 AM.
Reply With Quote
  #3  
Old 30-03-2009, 01:59 PM
webwizzy's Avatar

Administrator
 
Name: Vinayak
Join Date: Feb 2008
Location: India
Phone: Samsung Wave
Posts: 1,116
webwizzy is just really nicewebwizzy is just really nicewebwizzy is just really nicewebwizzy is just really nicewebwizzy is just really nice
Send a message via Yahoo to webwizzy
Default

Thanks wascally!

I think you posted a mod on vb.org called :

Alphabetical Search Menu.

It appears to be missing a few steps like the one to create the file page.php.
As Said by vbplusme
Alphabetical Search Menu for your vBulletin page

First of all, it isn't a mod, its an article. It just explains on how about achieving that. Its not a copy/paste code. It would require some php knowledge to get it going. Must read the Comments in the Code, have explained it to the max. The variables, table name, column names will have to be changed to go with your custom dynamic page.

The code wascally posted can help you. Here's a tutorial on how about creating a Custom vBulletin page.

Let me know if you have any problem.
__________________
Always TAG and SHARE your threads
Submit your site to TECH6 Directory
TECH6 on Facebook - Like Us

Would you like to Link To Us | Support TECH6 by going Premium
Know more about me at Vinayaks.com | Follow TECH6 at Twitter


Reply With Quote
  #4  
Old 30-03-2009, 02:08 PM
No Avatar

Learner
 
Join Date: Mar 2009
Posts: 5
wascallywabbit is on a distinguished road
Default

Glad it helped, but I am having massive problems getting mine to actually work.I have messed around til I am about ready to hang myself. I get one of two things when clicking a letter. Either I get a sql error about undefined columns or I get nothing but a white page.

I would love to get this working asap cause this is the on feature that my members love on the current phpbb3 site. So, I would REALLY appreciate all the help you can offer, keeping it simple, cause I am as mindless as a coma patient when it comes to this stuff :P

Thanks
Thanks
Reply With Quote
  #5  
Old 30-03-2009, 02:20 PM
webwizzy's Avatar

Administrator
 
Name: Vinayak
Join Date: Feb 2008
Location: India
Phone: Samsung Wave
Posts: 1,116
webwizzy is just really nicewebwizzy is just really nicewebwizzy is just really nicewebwizzy is just really nicewebwizzy is just really nice
Send a message via Yahoo to webwizzy
Default

See because this is an article, there may arise a LOT of changes to be done for the code to actually apply in your case.

1. Did you create the template as described in the article?
2. Are you sure your itemcount query is correct?
3. What is the exact error you get?

What is your custom page code and what are you trying to achieve?
__________________
Always TAG and SHARE your threads
Submit your site to TECH6 Directory
TECH6 on Facebook - Like Us

Would you like to Link To Us | Support TECH6 by going Premium
Know more about me at Vinayaks.com | Follow TECH6 at Twitter


Reply With Quote
  #6  
Old 30-03-2009, 03:10 PM
No Avatar

Learner
 
Join Date: Mar 2009
Posts: 5
wascallywabbit is on a distinguished road
Default

See because this is an article, there may arise a LOT of changes to be done for the code to actually apply in your case.

1. Did you create the template as described in the article?
2. Are you sure your itemcount query is correct?
3. What is the exact error you get?

What is your custom page code and what are you trying to achieve?
As Said by webwizzy View Post
1. Yeah
2. No, that is one of the things I am not sure about.
3. The error I get is just an undefined column error, so I know I am not setting up the counts and others correctly.

Also, I am not sure which database table I am even supposed to be pointing to. I thought it would be "threads" but then I looked at posts as well. When it comes to the itemcount querry, should it be something like threadid (for vb_thread) or postid (for vb_posts). I just have no clue which parts of the code I need to change and which I don't.

How's that for starters :S, I really wish I knew more about php, but I just don't so it can be frustrating doing this stuff
Reply With Quote
  #7  
Old 30-03-2009, 04:02 PM
webwizzy's Avatar

Administrator
 
Name: Vinayak
Join Date: Feb 2008
Location: India
Phone: Samsung Wave
Posts: 1,116
webwizzy is just really nicewebwizzy is just really nicewebwizzy is just really nicewebwizzy is just really nicewebwizzy is just really nice
Send a message via Yahoo to webwizzy
Default

err.. I did mention:-

Assuming you have intermediate knowledge of HTML and PHP.
As Said by Original Article
You see its really something that cannot be done unless you are totally aware of your database and have knowledge of php. I wish it would be a mod, download, upload and install hehe.
__________________
Always TAG and SHARE your threads
Submit your site to TECH6 Directory
TECH6 on Facebook - Like Us

Would you like to Link To Us | Support TECH6 by going Premium
Know more about me at Vinayaks.com | Follow TECH6 at Twitter


Reply With Quote
  #8  
Old 30-03-2009, 05:03 PM
No Avatar

Learner
 
Join Date: Mar 2009
Posts: 5
wascallywabbit is on a distinguished road
Default

I am fairly well versed in the sql part of it, the problem is more taking that information and getting it into the php script. For example, this section:
Code:
    // Count all log entries
    $itemcount = $db->query_first("
        SELECT COUNT(`threadid`) AS `itemcount`
        FROM `" . TABLE_PREFIX . "thread` WHERE title LIKE '" . $letter . "%'"); //Change colname to actual column name in table that you want to search in
Where I replaced the 'uid' with 'threadid' and the general statement "thread WHERE title like" I assumed I was supposed to put the sql table in the first part and the title for the column name.

Also, in this bit:
Code:
//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 . "thread WHERE title LIKE '" . $letter . "%' LIMIT " . ($limitlower - 1) . ", $perpage"); //Change colname to the same column name you had set in the above count query
I just repeated the information entered, but in the instructions it says to use the count query?

Finally, with this part:
Code:
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...
}
I am unsure what to change period.

I don't know if that will make it so you can help me, but if not, and you have the time, I will gladly allow you access to the database and site as it is running on my home computer, until I can get a lot of the kinks worked out with the phpbb3 transfer.

Thanks
Reply With Quote
  #9  
Old 30-03-2009, 06:50 PM
webwizzy's Avatar

Administrator
 
Name: Vinayak
Join Date: Feb 2008
Location: India
Phone: Samsung Wave
Posts: 1,116
webwizzy is just really nicewebwizzy is just really nicewebwizzy is just really nicewebwizzy is just really nicewebwizzy is just really nice
Send a message via Yahoo to webwizzy
Default

okay i have gone through your queries and they look fine to me. The thread table does exist in vb by default, threadid is the primarykey column and title column contains the thread's title.

Code:
while ($search_result = $db->fetch_array($query_Searchltr))
{
$row_id=$search_result['uid'];
$row_name=$search_result['name'];
// and so on...
}
In the above code (red part), these are the actual values that are retreived from the thread table and stored in variables. So in your case it should be something like (which should solve your unknown column problem):-

Code:
$row_id=$search_result['threadid'];
$row_name=$search_result['title'];
Now,

PHP Code:
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); 
This is the last part of the code. So as it says, simply create a template called mysearchbits and use the variables that store the value like $row_id, $row_name to print the output (which should solve your blank page problem as you have not created this template yet).

Hope it helps.
__________________
Always TAG and SHARE your threads
Submit your site to TECH6 Directory
TECH6 on Facebook - Like Us

Would you like to Link To Us | Support TECH6 by going Premium
Know more about me at Vinayaks.com | Follow TECH6 at Twitter


Reply With Quote
  #10  
Old 30-03-2009, 09:55 PM
No Avatar

Learner
 
Join Date: Mar 2009
Posts: 5
wascallywabbit is on a distinguished road
Default

Yeah, that gave me a start, but after going through your changes and seeing the results, I am wondering if I am doing something majorly wrong or am trying to do something that would require far more than I am capable. I guess the best way to describe what I want is to show you it on my current site and then if you say it's probably above what I can do, I will drop it . I have created a temporary account on it using the login: testuser and pw: testing. If you go to this link and login, you will see the alphabet list on the top and when you click a letter, only those posts in that forum section with that beginning letter are shown.

Now, I have made the changes you suggested and even gone as far as using the searchresults template to get it to show the results in the correct type layout. The problem is that when I click a letter, the result is pulled from any forum and it only shows one result and not in the "normal" table. I hope that makes some sense, but I am getting uber frustrated with myself and need to take a break from it for a few before I kill something.

Again thanks a ton for helping me thus far.
Reply With Quote
  #11  
Old 12-08-2010, 12:43 PM
No Avatar

Learner
 
Join Date: Aug 2010
Posts: 18
albertwilson is on a distinguished road
Default

I am thinking that I am suppose to create a custom page called page. php and add your php code to the bottom.
Reply With Quote
Reply

Bookmarks

Tags
alphabetical search menu


Thread Tools
Display Modes


LinkBacks (?)
LinkBack to this Thread: http://tech6.com/f51/need-completed-alphabetical-search-menu-code-t720/
Posted By For Type Date
vBPlusMe - About vBulletin Solutions Blog Archive Custom Templates - The Right Way This thread Refback 31-03-2009 07:25 AM



All times are GMT +5.5. The time now is 01:26 PM.

Contact Us - Tech6.com - Link to Us - Advertise - Submit Site - Privacy Statement - TOS - Top