Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+1 vote
306 views
in Q2A Core by
How to add image (banner) after every say 10 questions in list and same for the answers

I am trying to add using below code but its giving me error

$count = 0;
function q_list_item($q_item)
{
    $this->output('<DIV>');
    $this->my_items;    
    $this->output('</DIV>');

    $count++;           

    if($count % 3 == 0) {
        echo 'Hi this is the 3rd div';
    }

}
Q2A version: 1.5

2 Answers

0 votes
by
This may not work. You can add with jquery
+1 vote
by

It doesn't work because you can't have random variables outside of functions in a class. The way to do it would be to modify the loop in qa_list instead. This should work:

function q_list($q_list)
{
    if (isset($q_list['qs'])) {
        $this->output('<DIV CLASS="qa-q-list">', '');
        $count=0;
        foreach ($q_list['qs'] as $q_item) {
            $this->q_list_item($q_item);
            if ($count%3 == 0) {
                $this->output('Hi this is the 3rd div');
            }
            $count++;
        }
        $this->output('</DIV> <!-- END qa-q-list -->', '');
    }
}

 

 

by
Thanks its working but now its giving output to every list I want only on specific page not in all area
...