core.search_get_topic_data

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

core.search_get_topic_data

Post by iRusel » Mon May 07, 2018 3:49 pm

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
Extension Customisations
Extension Customisations
Posts: 3293
Joined: Sat Sep 10, 2011 7:12 pm
Location: Germany
Contact:

Re: core.search_get_topic_data

Post by kasimi » 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);

User avatar
iRusel
Registered User
Posts: 3
Joined: Mon May 07, 2018 3:41 pm

Re: core.search_get_topic_data

Post by iRusel » Mon May 07, 2018 11:02 pm

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
Registered User
Posts: 12984
Joined: Mon Apr 04, 2005 11:09 pm
Location: Milan (IT) Frankfurt (DE)
Name: Marco
Contact:

Re: core.search_get_topic_data

Post by 3Di » Mon May 07, 2018 11:38 pm

Show your full public function search_newpost_filter($event) as it is now, github is not updated.
Want to compensate me for my interest? Donate
Please PM me only to request paid works. Thx.
Extensions, Scripts, MOD porting, Update/Upgrades
My development's activity º PhpStorm's proud user

User avatar
3Di
Registered User
Posts: 12984
Joined: Mon Apr 04, 2005 11:09 pm
Location: Milan (IT) Frankfurt (DE)
Name: Marco
Contact:

Re: core.search_get_topic_data

Post by 3Di » 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.
Want to compensate me for my interest? Donate
Please PM me only to request paid works. Thx.
Extensions, Scripts, MOD porting, Update/Upgrades
My development's activity º PhpStorm's proud user

User avatar
posey
Registered User
Posts: 706
Joined: Tue Oct 06, 2009 7:34 pm
Location: The Netherlands
Name: Gijs

Re: core.search_get_topic_data

Post by posey » Tue May 08, 2018 12:46 am

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.
''I'm pretty sure there's a lot more to life than being really, really, ridiculously good looking. And I plan on finding out what that is.''

User avatar
iRusel
Registered User
Posts: 3
Joined: Mon May 07, 2018 3:41 pm

Re: core.search_get_topic_data

Post by iRusel » Mon May 14, 2018 2:24 pm

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
Registered User
Posts: 12984
Joined: Mon Apr 04, 2005 11:09 pm
Location: Milan (IT) Frankfurt (DE)
Name: Marco
Contact:

Re: core.search_get_topic_data

Post by 3Di » Tue May 15, 2018 2:05 am

$event['sql_where'] .= ' AND ' . $this->db->sql_in_set('t.forum_id', $forums_id_user); :?:
Want to compensate me for my interest? Donate
Please PM me only to request paid works. Thx.
Extensions, Scripts, MOD porting, Update/Upgrades
My development's activity º PhpStorm's proud user

Post Reply

Return to “Extension Writers Discussion”

Who is online

Users browsing this forum: Brf, Crizzo, Majestic-12 [Bot] and 13 guests