MyBB Community Forums

Full Version: Searching an extra colum in mybb.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am using the extra fields plugin for a new project of mine but i need to make it so MYBB will search it.

I am guessing i would need to modify the queery in search.inc so that it will search the extra colum (i think its an extra colum). The colum is called vin.

Any help with this would be great and i would happily register and make a few posts on your forum or put a link to your website on my new site if you can help me.

Thanks!
Yes, you would need to modify the query to do that. You'll probably also need to modify the query so that it joins with the extra profile fields table, so you can actually retrieve the values.
After that, you'll need to sanitize any input received, and then, add some sort of interface so that the user can search for it.
Can you be a little more specific with this. I dont understand the arrays (i think thats what they are) which change the queery.
Nup, don't need to worry about arrays (mostly).

You should know how to modify the query. If not, then I don't think you'll be able to make this modification.
As I said, you'll need to join the users table with the profile fields table, so that you can retrieve the data in the query set.
Ok,

Is this the queery i need to change, i looked through them all and this one seems most likely:

{
				$query = $db->query("SELECT DISTINCT f.fid FROM ".TABLE_PREFIX."forums f LEFT JOIN ".TABLE_PREFIX."forumpermissions p ON (f.fid=p.fid AND p.gid='".$mybb->user['usergroup']."') WHERE INSTR(CONCAT(',',parentlist,','),',$forum,') > 0 AND active!='no' AND (ISNULL(p.fid) OR p.cansearch='yes')");
				while($sforum = $db->fetch_array($query))
				{

So i would need to change this:
FROM ".TABLE_PREFIX."forums f LEFT JOIN ".TABLE_PREFIX."forumpermissions p ON (f.fid=p.fid AND p.gid='".$mybb->user['usergroup']."')

To something like this:
FROM ".TABLE_PREFIX."forums f LEFT JOIN ".TABLE_PREFIX."forumpermissions p ON (f.fid=p.fid AND p.gid='".$mybb->user['usergroup'] AND VIN."')

Or do i need to change what the TABLE_PREFIX means further up the code? Also is it inc/functions_search.php that i need to modify?
Nope.
I suggest you look into SQL syntax on how table joins work.

Might wanna read this as well: http://dev.mysql.com/doc/refman/5.0/en/join.html
Ok sorry i didnt provide the right information:

The extra field info is stored in a table called mbb_extrafields and the columb which contains the name vin is called field name. However the actuall contents of that extrafield is contained in the mybb_posts table in a columb called vin. Can you tell me if i am dealing with the right queery? (if you know)


Ps. Thanks for your help so far ZiNga BuRgA, i am currently reading the mysql thing above.
FROM ".TABLE_PREFIX."forums f LEFT JOIN (".TABLE_PREFIX."forumpermissions p ON (f.fid=p.fid AND p.gid='".$mybb->user['usergroup']."'), ".TABLE_PREFIX."posts p ON (vin))

Is this closer? I think what i am doing with this is joining the Posts table and selecting the VIN colum.