Advertisement:

Author Topic: code to get text of first post  (Read 3919 times)

Offline bjraines

  • Full Member
  • ***
  • Posts: 549
code to get text of first post
« on: August 21, 2008, 12:20:30 PM »
can someone help me with the code to get the text of the first post only in a thread?

Offline sawz

  • Charter Member
  • SMF Hero
  • *
  • Posts: 3,365
  • Gender: Male
  • getting older
Re: code to get text of first post
« Reply #1 on: August 21, 2008, 12:22:35 PM »
you mean like a preview of the thread?
http://custom.simplemachines.org/mods/index.php?mod=263
keep smiling, they'll always wonder what your up too.....

Offline bjraines

  • Full Member
  • ***
  • Posts: 549
Re: code to get text of first post
« Reply #2 on: August 21, 2008, 12:36:45 PM »
not exactly , i need to know how to code it , for a custom template i am doing....

Offline Dragooon

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 6,738
  • Gender: Male
  • I'm bIn
    • ShitizGarg on Facebook
    • Dragooon on GitHub
    • dragooon on LinkedIn
    • SMF-Media
Re: code to get text of first post
« Reply #3 on: August 21, 2008, 12:37:28 PM »
First of *what* thread?

Offline bjraines

  • Full Member
  • ***
  • Posts: 549
Re: code to get text of first post
« Reply #4 on: August 21, 2008, 12:42:26 PM »
the first topic

for example here someone has started a new thread

http://www.mychemistrytutor.com/forums/high-school-chemistry/quantum-mechanical-model/

i would to know the code, for this page, how to call the text of this first post.

Offline Dragooon

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 6,738
  • Gender: Male
  • I'm bIn
    • ShitizGarg on Facebook
    • Dragooon on GitHub
    • dragooon on LinkedIn
    • SMF-Media
Re: code to get text of first post
« Reply #5 on: August 21, 2008, 01:59:02 PM »
You can use the ID_FIRST_MSG(id_first_msg in smf 2) info in the topics table to link to the first post of the topic in messages table.
For example
Code: [Select]
SELECT t.ID_TOPIC, m.ID_MSG, m.subject, m.body
FROM {$db_prefix}topics AS t, {$db_prefix}messages AS m
WHERE t.ID_FIRST_MSG = m.ID_MSG
AND t.ID_TOPIC = <your topic id>
LIMIT 1
Is in SQL query which gets the first message of a specific topic.
To get some latest topic from one board this should do
Code: [Select]
SELECT t.ID_TOPIC, m.ID_MSG, m.subject, m.body
FROM {$db_prefix}topics AS t, {$db_prefix}messages AS m
WHERE t.ID_FIRST_MSG = m.ID_MSG
AND t.ID_BOARD = {your board id}
ORDER BY t.ID_TOPIC DESC
LIMIT 1
« Last Edit: August 21, 2008, 02:00:50 PM by Dragooon »

Offline bjraines

  • Full Member
  • ***
  • Posts: 549
Re: code to get text of first post
« Reply #6 on: September 15, 2008, 01:09:03 PM »
how would i use this in the forum template to echo the topics first message?