This is the community forum. For a developer response use the Client Area.
Follow us on Facebook, Twitter and YouTube!

Insert advertisements
#1

I want to insert some advertisements into the comments.
The way I'm trying to find is for instance insert a block after every 10th comment.

In what file would I do that and, if not to much asked, how would I do that?

Thanks
JohN
Reply
#2

Hi,

I haven't tested this.

- Open /comments/includes/functions/comments.php

- Search for $cmtx_comment_counter++; (there are 2 instances)

- Add the following on the lines above:

PHP Code:
<?php 
if (substr($cmtx_loop_counter, -1) == '0') {
echo
'test';
}

Basically it's checking whether the last number of the loop counter is 0. So it should echo at 10, 20, 30 etc.

Have you completed the interview?
Reply
#3

That works great Steven, thank you!
Reply
#4

How can we do this in the new version?
Reply
#5

In the latest version you'd need to open this file:
/frontend/view/default/template/main/comments.tpl

And before this:
<section class="cmtx_comment_section">

Add this:
PHP Code:
<?php
if (!isset($counter)) { $counter = 1; }
if (
in_array($counter, array(1,5))) {
echo
'test';
}
$counter++;
?>

It works a little differently to the earlier solution. With this one, it will target the first and fifth comment of each page, even if you're using the "More" button or infinite scroll. Of course, you can change the 1 and 5 to whatever you like.

Have you completed the interview?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)