MyBB Community Forums

Full Version: (not a mycode request) - Edit Search Function
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
EDIT: I was pretty sure I posted this in general support cause it's not a MyCode thing... I don't know if this topic got moved or if somehow I posted in the wrong one....

----

I looked into the Search.php file but I am a complete novice when it comes to php and I honestly have no idea what I'm looking at.

There's a place on the member profiles where you can search all their posts just by clicking the link. I'd like that search function to be edited to do 3 things:

1. Find only the posts in certain forums (fid = 1,2,3,4) ... etc. - My board is a roleplay and we only count the in-character posting, so I'd like the search to automatically search out only the posts from the forums where roleplay is happening.

2. Display results as a Topic list instead of a listing of individual posts. - Most people just want to look for a specific thread. The individual posts are a bit repetitive.

3. Get rid of the preview/snippet of the post. I just want to see the Thread title. Most of our users format their posts with tables, so all we end up seeing in the preview is a bunch of html tags.


.....

If anyone is able to help with this or give me a code-block to edit in, I'd be most grateful. Smile
bump bump. Smile
bump.
I think that this is actually in the member php.

On or about line 1452 there is this query:

$query = $db->simple_select("threads", "tid", "fid IN (0$flist) AND visible = 1", array('order_by' => 'lastpost', 'order_dir' => 'DESC', 'limit' => '1'));

You could try changing the variable (0$flist) to something like ('1','2','3'). If you do decide to edit a core file I suggest you use the patches plugin as it makes upgrades much easier.

Code not tested.
The "Find All Threads" link should filter by threads without post snips.

For the "Find All Posts"..

(2014-04-04, 03:51 AM)Leefish Wrote: [ -> ]I think that this is actually in the member php.

On or about line 1452 there is this query:

$query = $db->simple_select("threads", "tid", "fid IN (0$flist) AND visible = 1", array('order_by' => 'lastpost', 'order_dir' => 'DESC', 'limit' => '1'));

You could try changing the variable (0$flist) to something like ('1','2','3'). If you do decide to edit a core file I suggest you use the patches plugin as it makes upgrades much easier.

Code not tested.

It is actually in the search.php file, replace:
$where_sql = "uid='".intval($mybb->input['uid'])."'";

With:
$where_sql = "uid='".intval($mybb->input['uid'])."' AND fid IN ('1', '2', '3')";

Where 1, 2, and 3 are the allowed forums to search in.

To snip HTML, MyCode, and quotes from psot results, there was a plugin/mod of mine around here I couldn't find now xD
(2014-04-04, 04:39 AM)Omar G. Wrote: [ -> ]The "Find All Threads" link should filter by threads without post snips.

That only finds threads that were started by the user. I want to find any thread where that user has posted, so editing the search posts to only display the topic title works better... I did find that the preview code is in the templates so I removed that on my own.

I've edited the last bits in the templates to do what I want.

Thanks so much for looking into this and helping me out!

Leefish Wrote:If you do decide to edit a core file I suggest you use the patches plugin as it makes upgrades much easier.


I have no idea how to do that... I've actually edited several of the core files, and yah it is a tad annoying when I do upgrades to the newest version and it erases my edits; but I really don't know much about using plugins (and no idea what patches even are). I modified a few pluggins to do different things but I'm basically a noob when it comes to coding.
Big Grin Big Grin Big Grin