Add ads before last post

Started by peppe, October 01, 2010, 08:38:05 AM

Previous topic - Next topic

peppe

Hi.

I've seen this topic (click here) and here we can see the way to put the ads after the first post. But i'd want, if it's possible, to put it before last post of all discussion page.

How can i do it? Please help me.

Thanks for all your opinion,
best regards
Tutte le news sulla laurea in giurisprudenza e su esame da avvocato

Kays

Hi, that won't be that easy as the first message is identified. But the last message isn't.

Also where would it go if there's no replies?

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

peppe

Quote from: Kays on October 01, 2010, 09:20:18 AM
Hi, that won't be that easy as the first message is identified. But the last message isn't.

Also where would it go if there's no replies?
It can go before the first message, if there's no replies. But if it's difficult it's a big problem, because a lot of people read the last post, more than people that read the first.
Tutte le news sulla laurea in giurisprudenza e su esame da avvocato

Kays

Sounds like a logical reason.:)

It looks like it's not that difficult to identify the very last post in a topic.

In Display.php look for:


'counter' => $counter,


and add after it:


'is_last' => $context['num_replies'] == $counter,


Then in display.template.php, after:


while ($message = $context['get_message']())
{


You can add something like this to show the ad:


if($message['is_last'])
echo '
<tr><td>Ad code goes here</td></tr>';


That is for the 1.1.x default theme. So you'll probably need to change the html to suite your theme. This should work for 2.0 also.

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

agent47

Theres a Mod that can help you with that.
You can place advertisements at various places using this mod. I use it with my forum aswell. Works pretty well

http://custom.simplemachines.org/mods/index.php?mod=255

PortaMx is probably the best SMF portal!

Hj Ahmad Rasyid Hj Ismail

Quote from: Kays on October 02, 2010, 12:44:24 AM
Sounds like a logical reason.:)

It looks like it's not that difficult to identify the very last post in a topic.

In Display.php look for:


'counter' => $counter,


and add after it:


'is_last' => $context['num_replies'] == $counter,


Then in display.template.php, after:


while ($message = $context['get_message']())
{


You can add something like this to show the ad:


if($message['is_last'])
echo '
<tr><td>Ad code goes here</td></tr>';


That is for the 1.1.x default theme. So you'll probably need to change the html to suite your theme. This should work for 2.0 also.
Thank you very much for the solution Kays. It was asked before and no one seems to have a solution for it. Thanks again.

Advertisement: