core.search_get_topic_data

Discussion forum for Extension Writers regarding Extension Development.
Post Reply
iRusel
Registered User
Posts: 3
Joined: Mon May 07, 2018 3:41 pm

core.search_get_topic_data

Post by iRusel »

Tell me how to change forums_id.

Made through sql_where:

Code: Select all

$forums_id_ary = array("1","2","3");
$event['sql_where'] = " t.forum_id IN (" . $forums_id_ary . ") ";
The code works, but shows all the topics in the "New Messages" section, there is also no pagination.

GitHub: main_listener.php
Sorry for my bad english.
User avatar
kasimi
Former Team Member
Posts: 4900
Joined: Sat Sep 10, 2011 7:12 pm
Location: Germany
Contact:

Re: core.search_get_topic_data

Post by kasimi »

Try appending to the existing sql_where value instead of overwriting it. Also you should be using $db->sql_in_set():

Code: Select all

$event['sql_where'] .= ' AND ' . $this->db->sql_in_set('t.forum_id', $forums_id_ary);
iRusel
Registered User
Posts: 3
Joined: Mon May 07, 2018 3:41 pm

Re: core.search_get_topic_data

Post by iRusel »

kasimi wrote: Mon May 07, 2018 8:38 pm Try appending to the existing sql_where value instead of overwriting it. Also you should be using $db->sql_in_set():

Code: Select all

$event['sql_where'] .= ' AND ' . $this->db->sql_in_set('t.forum_id', $forums_id_ary);
Not working.

SQL:

Code: Select all

SELECT t.*, f.forum_id, f.forum_name, tp.topic_posted, tt.mark_time, ft.mark_time as f_mark_time FROM for_topics t LEFT JOIN for_forums f ON (f.forum_id = t.forum_id) LEFT JOIN for_topics_posted tp ON (tp.user_id = 2 AND t.topic_id = tp.topic_id) LEFT JOIN for_topics_track tt ON (tt.user_id = 2 AND t.topic_id = tt.topic_id) LEFT JOIN for_forums_track ft ON (ft.user_id = 2 AND ft.forum_id = f.forum_id) WHERE t.topic_id IN (24, 23, 22, 5, 21, 20, 19, 30, 25, 26, 27, 28, 29, 31, 11, 10, 9, 8, 7, 32, 4, 33, 34, 18, 17) AND ((1=1 AND t.topic_visibility = 1) OR t.forum_id IN (1, 2, 3, 4, 5, 6, 7, 8, 9, 10)) AND t.forum_id = '2,3,4,6' ORDER BY t.topic_last_post_time DESC
Sorry for my bad english.
User avatar
3Di
I've Been Banned!
Posts: 17538
Joined: Mon Apr 04, 2005 11:09 pm
Location: I'm with Ukraine 🇺🇦
Name: Marco
Contact:

Re: core.search_get_topic_data

Post by 3Di »

Show your full public function search_newpost_filter($event) as it is now, github is not updated.
🆓 Free support for our extensions also provided here: phpBB Studio
🚀 Looking for a specific feature or alternative option? We will rock you!
Please PM me only to request paid works. Thx. Buy me a coffee -> Image
My development's activity º PhpStorm's proud user º Extensions, Scripts, MOD porting, Update/Upgrades
User avatar
3Di
I've Been Banned!
Posts: 17538
Joined: Mon Apr 04, 2005 11:09 pm
Location: I'm with Ukraine 🇺🇦
Name: Marco
Contact:

Re: core.search_get_topic_data

Post by 3Di »

Try this: f.forum_id instead of t.forum_id

Code: Select all

$event['sql_where'] .= ' AND ' . $this->db->sql_in_set('f.forum_id', $forums_id_ary);
Not tested.
🆓 Free support for our extensions also provided here: phpBB Studio
🚀 Looking for a specific feature or alternative option? We will rock you!
Please PM me only to request paid works. Thx. Buy me a coffee -> Image
My development's activity º PhpStorm's proud user º Extensions, Scripts, MOD porting, Update/Upgrades
User avatar
mrgoldy
Former Team Member
Posts: 1394
Joined: Tue Oct 06, 2009 7:34 pm
Location: The Netherlands
Name: Gijs
Contact:

Re: core.search_get_topic_data

Post by mrgoldy »

Could you indeed your full code, please?

As in your SQL query you still have AND t.forum_id = '2,3,4,6' which is not correct.
phpBB Studio / Member of the Studio

Contributing: You can do it too! Including testing Pull Requests (PR).
phpBB Development and Testing made easy.
iRusel
Registered User
Posts: 3
Joined: Mon May 07, 2018 3:41 pm

Re: core.search_get_topic_data

Post by iRusel »

3Di wrote: Mon May 07, 2018 11:38 pm Show your full public function search_newpost_filter($event) as it is now, github is not updated.

Code: Select all

public function search_newpost_filter($event)
	{		
		$forums_id = $this->user->data['user_newpost_filter'];
		if($forums_id)
		{
			$forums_id_ary = str_replace(" ", ",", $forums_id);
			$forums_id_user = explode(",", $forums_id);
			$event['sql_where'] = " t.forum_id IN (" . $forums_id_ary . ") ";			
	}
My version.
Works but is not correct.
3Di wrote: Mon May 07, 2018 11:52 pm Try this: f.forum_id instead of t.forum_id

Code: Select all

$event['sql_where'] .= ' AND ' . $this->db->sql_in_set('f.forum_id', $forums_id_ary);
Not tested.
Not Working.
posey wrote: Tue May 08, 2018 12:46 am Could you indeed your full code, please?
main_listener.php
Sorry for my bad english.
User avatar
3Di
I've Been Banned!
Posts: 17538
Joined: Mon Apr 04, 2005 11:09 pm
Location: I'm with Ukraine 🇺🇦
Name: Marco
Contact:

Re: core.search_get_topic_data

Post by 3Di »

$event['sql_where'] .= ' AND ' . $this->db->sql_in_set('t.forum_id', $forums_id_user); :?:
🆓 Free support for our extensions also provided here: phpBB Studio
🚀 Looking for a specific feature or alternative option? We will rock you!
Please PM me only to request paid works. Thx. Buy me a coffee -> Image
My development's activity º PhpStorm's proud user º Extensions, Scripts, MOD porting, Update/Upgrades
Post Reply

Return to “Extension Writers Discussion”