Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Aiheen aloitti: PokémonS - tammikuu 18, 2014, 09:27:50 AP

Otsikko: Don't show if there are 8 posts in a page.
Kirjoitti: PokémonS - tammikuu 18, 2014, 09:27:50 AP
SMF 2.0.6

Hi,
I already have this code, added below the signature:

if ($message['counter'] % 15 == 7) {
echo 'content'
}


How to hide the content if there are 8 posts in a page?
And display the content if there are >8 posts in a page?


Edit:
I want display the content for the 8th post, but it's only displayed if the total of posts in a page is >8 posts.

Thx.
Otsikko: Re: Don't show if there are 8 posts in a page.
Kirjoitti: The Wizard - tammikuu 18, 2014, 09:36:13 AP
Something like this -   


if ($message['counter'] => 8)
{
what ever you want to happen after 8
} else {
what ever you want to happen before 8
}



Otsikko: Re: Don't show if there are 8 posts in a page.
Kirjoitti: PokémonS - tammikuu 18, 2014, 10:15:00 AP
@The Wizard,
Thanks for your answer.

I try this:

if ($message['counter'] => 8) {
if ($message['counter'] % 15 == 7) {
echo 'content';
}
}


But it's not what I looking for.
I want display the content for the 8th post, but it's only displayed if the total of posts in a page is >8 posts.

And sorry for my previous message, a little ambiguous, but I have edited it. :)
Otsikko: Re: Don't show if there are 8 posts in a page.
Kirjoitti: margarett - tammikuu 18, 2014, 01:33:39 IP
There was recently a similar question, regarding the 21st post. Can't find it now but it should solve your issue (considering the necessary adjustments)
Otsikko: Re: Don't show if there are 8 posts in a page.
Kirjoitti: PokémonS - tammikuu 18, 2014, 11:12:34 IP
@margarett,

Yes, that's my question too.
-> http://www.simplemachines.org/community/index.php?topic=516811.0

But now, I want to display "the content" in 8th post if the total of posts in a page is >8 posts.
Otsikko: Re: Don't show if there are 8 posts in a page.
Kirjoitti: margarett - tammikuu 19, 2014, 01:51:41 AP
Just OR you first condition with
(counter == 8)
(Sorry I'm on the phone now, it's not very good to write code :P )
Otsikko: Re: Don't show if there are 8 posts in a page.
Kirjoitti: PokémonS - tammikuu 19, 2014, 03:17:21 AP
@margarett,

Thanks for your answer.
I tried this:

if (($message['counter'] % 15 == 7) or (counter == 8)) {
echo 'content';
}


But "the content" in 8th post is still displayed in 8th post.
I want the "the content" in 8th post is displayed if the total of post in a page is 9 posts or more.
Otsikko: Re: Don't show if there are 8 posts in a page.
Kirjoitti: margarett - tammikuu 19, 2014, 08:41:40 AP
The Wizard's code should do it, just use > instead of >=

I thought that you want to show it in the 8th post as well.