Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.

Difference in custom content output v1.5.4 versus v1.6.2

+1 vote
asked Oct 14, 2013 in Plugins by q2apro
Just realized by transferring some plugins to the latest q2a version 1.6.2 that the custom output is handled differently now.

Before we had to define:

$c = 2;
$qa_content['custom'.++$c]='<p>my output</p>";
$qa_content['custom'.++$c]='<p>my output II</p>";

which gave a clean output in 1.5.4:

<p>my output</p> <p>my output II</p>

Now in v1.6.2 I get this instead:

<div class="qa-part-custom3">
   <p>my output</p>

<div class="qa-part-custom4">
   <p>my output II</p>

Why was that changed? That could corrupt a lot of plugins I assume.
Q2A version: 1.6.2
commented Oct 14, 2013 by q2apro
*** How can we output now the content without these extra classes??

2 Answers

+1 vote
answered Oct 14, 2013 by jatin.soni

Yes you are right.. I had problem with lot of custom plugin I have done for clients.

Only simple different is you can do is just concatenate the previous $content variable using .=

So the code witll be in this way

$qa_content['custom']  = 'your first line'; //usually very first string or empty

$qa_content['custom'].='<p>my output</p>";

$qa_content['custom'].='<p>my output II</p>";

commented Oct 15, 2013 by q2apro
When I use AJAX features, throw a request to a page, I receive also these new DIVs inside. :(

On the other hand, I understand that Gideon wants to make it clear that this is custom information by adding the DIV(s). However, I guess this is not necessary. Especially not if I am on a page that has been created by a plugin.

Btw, this is why I am always very careful if it comes to updates. They can lead to new problems and a lot of extra work :(
commented Oct 15, 2013 by q2apro
The responsible part for those extra classes is: qa-theme-base.php, from line 744 to 748:

if ($partdiv)
    $this->output('<div class="qa-part-'.strtr($key, '_', '-').'">'); // to help target CSS to page parts

if (strpos($key, 'custom')===0)

The extra classes are unnecessary in my point of view. I have not seen any plugin that targets e.g. "qa-part-custom3".
commented Oct 16, 2013 by jatin.soni
Thanks Kai you found the reason.. I

In fact I have already requested here to remove wrapper for custom content. I found it is useless since developer most of the time adds own wrapper.
commented Oct 16, 2013 by q2apro
absolutely right, nice that we think the same here :)
0 votes
answered Oct 15, 2013 by q2apro

I am sad to say that but I did a core hack to solve this problem, it is a one liner (I know I could override function main_part() but I don't see the point in adding 50 lines to my theme file when I can remove 1 line in the core...

qa-theme-base.php remove line 733: (strpos($key, 'custom')===0) ||

Now my plugins work again!