Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+1 vote
592 views
in Q2A Core by
i am going to edit answer so i will get the answer

the get length of answer and put adsense in middle so i try to know where i need to change exactly

 

plz provide file name and variables to get the all answer

1 Answer

+1 vote
by

Hello, in your theme's qa-theme.php file add the following code snippet in side the class qa_html_theme:

FOR adding adcode in between question:

function q_view_content($q_view)
{
if (!empty($q_view['content'])) {
$text = $q_view['content'];
 
$part1 = substr($text, 0, floor(strlen($text) / 2));
$part2 = substr($text, floor(strlen($text) / 2));
 
if (substr($part1, 0, -1) != ' ' AND substr($part2, 0, 1) != ' ')
{
   $middle = strlen($part1) + strpos($part2, ' ') + 1;
}
else
{
   $middle = strrpos(substr($text, 0, floor(strlen($text) / 2)), ' ') + 1;    
}
 
$part1f = substr($text, 0, $middle);  // "The Quick : Brown Fox Jumped "
$part2f = substr($text, $middle);  // "Over The Lazy / Dog"
 
//Replace your AD Code here
$adcode = "<br /><br />YOUR AD HERE<br />YOUR AD HERE<br /><br />";
 
$this->output('<div class="qa-q-view-content">');
$this->output_raw($part1f . $adcode . $part2f);
$this->output('</div>');
}
//qa_html_theme_base::q_view_content($q_view);
}
 
For adding ad code in between answer:
 
function a_item_content($a_item)
{
 
$text = $a_item['content'];
 
$part1 = substr($text, 0, floor(strlen($text) / 2));
$part2 = substr($text, floor(strlen($text) / 2));
 
if (substr($part1, 0, -1) != ' ' AND substr($part2, 0, 1) != ' ')
{
  $middle = strlen($part1) + strpos($part2, ' ') + 1;
}
else
{
  $middle = strrpos(substr($text, 0, floor(strlen($text) / 2)), ' ') + 1;    
}
 
$part1f = substr($text, 0, $middle);  // "The Quick : Brown Fox Jumped "
$part2f = substr($text, $middle);  // "Over The Lazy / Dog"
 
//Replace your AD Code here
$adcode = "<br /><br />YOUR AD HERE<br />YOUR AD HERE<br /><br />";
 
$this->output('<div class="qa-a-item-content">');
$this->output_raw($part1f . $adcode . $part2f);
$this->output('</div>');
//qa_html_theme_base::a_item_content($a_item);
}
 
Replace you AD code at the point where it is commented as such
by
I think google will penalise my ads account if i place multiple ads in question and then answer
...