Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Aiheen aloitti: PokémonS - tammikuu 11, 2014, 02:57:33 AP

Otsikko: Add content below signature
Kirjoitti: PokémonS - tammikuu 11, 2014, 02:57:33 AP
SMF 2.0.6

Hi,
I already add some content below signature for the first post, I use:

if ($message['id'] == $context['topic_first_message']) {
echo 'content here';
}


The content is only displayed for first post.
How to display the content for 21st post, 41st post, 61st post... and so on?

Thx.
Otsikko: Re: Add content below signature
Kirjoitti: Kays - tammikuu 11, 2014, 09:13:19 AP
Try using something like this instead. It should only show something for the the first post on each page.


if (!isset($show_this))
{
echo 'content here';
$show_this = true;
}
Otsikko: Re: Add content below signature
Kirjoitti: Oldiesmann - tammikuu 11, 2014, 12:45:16 IP
Take a look at $message['counter']. That will tell you what reply # that message is (0 for the first post in the topic, 1 for the first reply, etc.).

For example, to display something after the 21st post:

if ($message['counter'] == 20)
{
// Code to display whatever you want here
}
Otsikko: Re: Add content below signature
Kirjoitti: Chen Zhen - tammikuu 11, 2014, 10:54:30 IP
PokémonS,


if ($message['id'] % 20 == 1) {
echo 'content here';
}
Otsikko: Re: Add content below signature
Kirjoitti: PokémonS - tammikuu 11, 2014, 11:29:39 IP
Thanks all!
Everyone's codes are worked perfectly. :3