Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.
Not a member yet? Click here to register.
Forgot Password?

Output the first post of the topic

Asked Modified Viewed 1,413 times
A
Alex-newcode-NSK
A
  • Newbie, joined since
  • Contributed 3 posts on the community forums.
  • Started 1 thread in the forums
  • Started this discussions
asked
Newbie

Hello! Please help me bring the first post of the topic to the forum_threads_list_panel panel.

On the main page of the site where this panel is enabled, and in it I want to make the first post of the topic show under the name of each topic
0 replies

4 posts

C
Chan
C
Chan 0
Lead Developer of PHP-Fusion
  • Super Admin, joined since
  • Contributed 3,841 posts on the community forums.
  • Started 232 threads in the forums
  • Answered 6 questions
answered
Super Admin

Give me the HTML layout format of your desired output or you want just the SQL? For the earlier, just make a screenshot of where is what with marker pen and attach in your response. I'll help you if I know what to do.
Edited by Chan on 18-05-2022 13:31,
0 replies
A
Alex-newcode-NSK
A
  • Newbie, joined since
  • Contributed 3 posts on the community forums.
  • Started 1 thread in the forums
  • Started this discussions
answered
Newbie

php-fusion 8.00.100
file: /infusions/forum_threads_list_panel/forum_threads_list_panel.php

linkme.ufanet.ru/images/b84ceb0bb336d7b3c5a0b5ceb2069e8a.jpg


What I highlighted in red, it is necessary to make the conclusion of the first post of this topic there

Please
0 replies
C
Chan
C
Chan 0
Lead Developer of PHP-Fusion
  • Super Admin, joined since
  • Contributed 3,841 posts on the community forums.
  • Started 232 threads in the forums
  • Answered 6 questions
answered
Super Admin

Sorry for the late reply.

There are 2 things you need to change to achieve that.

1. This is the column output, see that $data['forum_name'] you need to swap it out with the text.

https://github.com/PHPFusion/PHPFusion/blob/Tesseract/infusions/forum_threads_list_panel/forum_threads_list_panel.php#L85


So at the last bit, Lets change
trimlink($data['thread_subject'], 30)."</a><br />n".$data['forum_name']."
to
trimlink($data['thread_subject'], 30)."</a><br />n".$data['first_post_text']."


2. Next, this is the SQL query bit that we need to alter to output a new data column.

https://github.com/PHPFusion/PHPFusion/blob/Tesseract/infusions/forum_threads_list_panel/forum_threads_list_panel.php#L43-L54

Since we need the new first_post_text, we need to redo this query a bit.

Change:

$result = dbquery(
 "SELECT   f.forum_id, f.forum_cat, f.forum_name, f.forum_description, f.forum_moderators, f.forum_lastpost, f.forum_postcount,
 f.forum_threadcount, f.forum_lastuser, f.forum_access, f2.forum_name AS forum_cat_name, f2.forum_description AS forum_cat_description,
 t.thread_id, t.thread_lastpost, t.thread_lastpostid, t.thread_subject, t.thread_postcount, t.thread_views, t.thread_lastuser, t.thread_poll,
 u.user_id, u.user_name, u.user_status, u.user_avatar
 FROM ".DB_FORUMS." f
 LEFT JOIN ".DB_FORUMS." f2 ON f.forum_cat = f2.forum_id
 LEFT JOIN ".DB_THREADS." t ON f.forum_id = t.forum_id AND f.forum_lastpost=t.thread_lastpost
 LEFT JOIN ".DB_USERS." u ON f.forum_lastuser = u.user_id
 ".(multilang_table("FO") ? "WHERE f2.forum_language='".LANGUAGE."' AND" : "WHERE")." ".groupaccess('f.forum_access')." AND f.forum_cat!='0' AND t.thread_lastpost >= ".$timeframe." AND t.thread_hidden='0'
 GROUP BY thread_id ORDER BY t.thread_lastpost LIMIT ".$settings['numofthreads'].""
);


$result = dbquery(
 "SELECT   f.forum_id, f.forum_cat, f.forum_name, f.forum_description, f.forum_moderators, f.forum_lastpost, f.forum_postcount,
 f.forum_threadcount, f.forum_lastuser, f.forum_access, f2.forum_name AS forum_cat_name, f2.forum_description AS forum_cat_description,
 t.thread_id, t.thread_lastpost, t.thread_lastpostid, t.thread_subject, t.thread_postcount, t.thread_views, t.thread_lastuser, t.thread_poll,
 u.user_id, u.user_name, u.user_status, u.user_avatar,
 (SELECT post_message FROM ".DB_POSTS." WHERE thread_id=t.thread_id ORDER BY post_id ASC LIMIT 1) AS first_post_text
 FROM ".DB_FORUMS." f
 LEFT JOIN ".DB_FORUMS." f2 ON f.forum_cat = f2.forum_id
 LEFT JOIN ".DB_THREADS." t ON f.forum_id = t.forum_id AND f.forum_lastpost=t.thread_lastpost
 LEFT JOIN ".DB_USERS." u ON f.forum_lastuser = u.user_id
 ".(multilang_table("FO") ? "WHERE f2.forum_language='".LANGUAGE."' AND" : "WHERE")." ".groupaccess('f.forum_access')." AND f.forum_cat!='0' AND t.thread_lastpost >= ".$timeframe." AND t.thread_hidden='0'
 GROUP BY thread_id ORDER BY t.thread_lastpost LIMIT ".$settings['numofthreads'].""
);


Let me know if it works for you. Screenshot of my test for the SQL.

And the text might be very long, so I suggest you to trim it, using trimlink function, or use CSS to line wrap it in 1 line.
As forum text might contain bbcode, you might want to use the parseubb function.
Chan attached the following image:
Image not found
0 replies
A
Alex-newcode-NSK
A
  • Newbie, joined since
  • Contributed 3 posts on the community forums.
  • Started 1 thread in the forums
  • Started this discussions
answered
Newbie

Chan, Thank you very much, it works as I wanted!
0 replies

Category Forum

Panels and Infusions

Labels

None yet

Statistics

  • Views 0 views
  • Posts 4 posts
  • Votes 0 votes
  • Topic users 2 members

2 participants

C
C
Chan 0
Lead Developer of PHP-Fusion
  • Super Admin, joined since
  • Contributed 3,841 posts on the community forums.
  • Started 232 threads in the forums
  • Answered 6 questions
A
A
  • Newbie, joined since
  • Contributed 3 posts on the community forums.
  • Started 1 thread in the forums
  • Started this discussions

Notifications

Track thread

You are not receiving notifications from this thread.

Related Questions

Not yet