News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

How to get a first message text by topic id ?

Started by exn, November 15, 2009, 03:10:47 PM

Previous topic - Next topic

exn

Hello !

  I want to show a message on some part of the template from first message of the topic with id for example 33. How can I do it ???


Help me please.

Thanks !
I'm using smf 1.1.10

exn

Any suggestions ??? I can't find anything similar to it  :(
I'm using smf 1.1.10

DavidCT

I read your message a dozen times and can't figure out what you want... maybe explaining it better and in detail will help.

Arantor

Please don't bump within 24 hours of an initial post (and definitely not within half an hour) - please remember we're all volunteers here.

We do need more information. What exactly are you trying to achieve?

exn

How to access to the first message or subject or anything by topic id from the template ? to display it (it my problem how to display, main problem is access to it)
  variable name, or function or anything.. i'm serching loong time and can't find anything. I think instead of making a 2.0 version developers must been made a documentation..
I'm using smf 1.1.10

Arantor

Which template?

What do you want to do with it? Where do you want to display it?


Btw, if we wrote the documentation for 1.1, 2.0 would have been even MORE delayed. It's already over a year late and we're not at final yet.

exn

Quote from: Arantor on November 15, 2009, 07:02:44 PM
Which template?


  It's a very very good question. Board_index :)  to display on Board_index of course.
I'm using smf 1.1.10

Arantor

So you want to display a post on the board index.

What topic do you want to get it from?

exn

I want to display only first post from the topic. at the index page, for test it even can be without any nifty html things. just get it from and put to the page. it's very hard ?

aah, forget to say, 1.1.10
I'm using smf 1.1.10

Arantor

As I already asked, I need to know which topic it is you want to get.

I already guessed it was 1.1.10, since you were in the 1.x support board, though the process would be the same for any 1.1.x version.

Oh, and exactly WHERE on the page? Above the board index itself, but below the top header? Below the board index and above the footer, bottom of the page?

What theme are you using, too?

* Arantor will move this to Coding Discussion unless you have any real objections.

exn

It's important  :o

  I'll put at top of the boardindex, after the "global" definetion  staff.  how, tell me how to get the content from the particular topic ? 
  also i guess there not possibility to access directly to it from the template, need to define it in the
general script. it's true ? can you say me anything helpful ?
I'm using smf 1.1.10

Arantor

Oh, I can tell you how to do it precisely, but I cannot until you tell me:
1. As requested, what topic you want
2. What theme you're using

I can tell you anything you need to know about the code, what needs to be modified in Sources/BoardIndex.php, Themes/yourtheme/Boardindex.template.php, what database queries you'll need, how to call the bbcode parser, but until you answer my questions, I CANNOT HELP YOU.

You also should NEVER put queries in the templates.

exn

ah, nono, my goal are simple put a text from the topic
  Topic located at the specialboard->messageoftheday
  I want to display a text, without any bb codes and so on. It will be like

   get text from the first post of the topic by id (or name or anything, just from there specialboard->messageoftheday) and put it to the boardindex for anyone.

Default theme.
I'm using smf 1.1.10

Arantor

OK FINALLY we're getting somewhere.

So, you want... what... the most recent topic from that board to be displayed? What's the board id?

exn

from here 348328.msg2359643 and only from here.
I'm using smf 1.1.10

Arantor

Only ever that topic, cool. And post 2359643 is the very first post in that thread? Cool, makes it simpler for me.

Sources/BoardIndex.php
Code (find) Select
// Remember the most recent topic for optimizing the recent posts feature.

Code (before that, add) Select
// Get the first post from our announcements, msg 2359643, from thread 348328
$query = db_query("SELECT body FROM {$db_prefix}messages WHERE ID_MSG = 2359643", __FILE__, __LINE__);
$context['special_message'] = '';
if($row = mysql_fetch_row($query))
$context['special_message'] = parse_bbc($row[0]);


Themes/default/BoardIndex.template.php
Code (find) Select
// Show the news fader?  (assuming there are things to show...)

Code (before that, add) Select
// Display our special announcement
if(!empty($context['special_message']))
echo '
<table border="0" width="100%" class="tborder" cellspacing="' , ($context['browser']['is_ie'] || $context['browser']['is_opera6']) ? '1' : '0' , '" cellpadding="4" style="margin-bottom: 2ex;">
<tr>
<td class="catbg"> Message of the Day</td>
</tr>
<tr>
<td valign="middle" align="center">', $context['special_message'], '</td>
</tr>
</table>';


You didn't specify how it should look on the page so I turned it into a simple block. Let me know if you want to change it.   

exn

Thank you !

  I'll try it as soon as will fix one a strange error..  other topic.
I'm using smf 1.1.10

Advertisement: