Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+1 vote
1.0k views
in Plugins by
Hi, I need to manipulate the final output before it goes out to browser.  I manage to hack the core to do it, but is there a plugin/more elegant way to do this.

Side note: I am doing this for adsense plugin.  I found that the plugin loads before the logic of the page is fully executed.  So based on page's logic, I need to turn adsense blocks on/off.
Q2A version: 1.7
by
alternatively, how do "late execute" a plugin - i.e. after the page has completed its full logic.
by
@Leo, adsense used to hand out medals. Now they only ban you :)
by
What exactly do you need to do?
by
hi @pupi1985, I need to get control of the output stream. So I can turn adsense blocks on/off depending on certain conditions (e.g. don't show adsense on user banned page).

I already got it working using 'shutdown', please see my answer.  For adsense, I could also hook it to shutdown which is a much more elegant solution.
by
@Leo, let's say a person has a very bad name.  The user page still shows (at least I believe..).  So I had to post-process it.

1 Answer

+1 vote
by

I think I figured it out actually, and thanks to @Leo for hints.   The way to do it is to use the shutdown($reason) process module http://www.question2answer.org/modules.php?module=process and use ob_start to manipulate the output stream.  I am not good with writing plugins yet, but that is the correct direction, I believe.

by
My advise:
As Gideon is described, process module is a module in order to intervene in the basic (overall) operation of the Q2A. For example, it is used by caching plugin which I am developing now.

Quote:
A process module (requires Q2A 1.5+) can perform any task at specific stages of Q2A's response processing. For example, process modules could provide logging, implement a page cache, change database settings, or perform extra user authentication.

adsense plugin is small widget module. So, more appropriate approach for you would be to intervene in the widget control of Q2A.
by
Thanks, @Sama55, but it seems adsense plugin actives earlier than some of the page logic.
by
I want to check just in case. Is your "adsense plugin" "qa-plugin/basic-adsense" in Q2A?
by
yes, basic-adsense
by
Do you know "Widget Anywhere"?
http://www.question2answer.org/qa/15066
Feature is different, but this plugin has know-how related to widget control. This plugin is simple. However, very powerful. Analysis will not be difficult.
by
Thanks, @sama55.  Interesting plugin.  I will check it out.

Welcome to the Q&A site for Question2Answer.

If you have a question about Q2A, please ask here, in English.

To report a bug, please create a new issue on Github or ask a question here with the bug tag.

If you just want to try Q2A, please use the demo site.

Categories

...