Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Admin Plugin -- Edit Admin Screen
When i want to add something to Admin Screen, i used Javascript to display my plugin.
But to add a javascript by php that rearrange the html which also comes from php…
Perhaps not methode of choice.
Today i played a little with php’s output buffer, that is already used in txp.
This just adds a link before the ‘Textile Help’ and it seems to work.
<pre><code>
if (@txpinterface == ‘admin’)
register_callback(“my_buffer”, “article”);
function my_buffer() {
$buffer = ob_get_clean();
// The pattern is taken from include/txp_article.php
$pattern = ‘<p><a href=”#” onclick=“toggleDisplay(\‘textile_help\’);”>’.gTxt(‘textile_help’).’</a></p>’;
//I want to add a js-link:
$add = ‘<p><a href=“javascript:doSomeThing()”>My Plugin</a></p>’.$pattern;
$buffer = str_replace($pattern,$add,$buffer);
echo $buffer;
}
</code></pre>
I never used the output buffer before.
I this the right methode to work with the buffer? Probably not.
If anybody has experience with this buffer thing:
How can i make sure, that other plugins can use the (modifed) buffer also?
Offline
#2 2005-10-08 20:05:44
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: Admin Plugin -- Edit Admin Screen
Yeah, I discovered recently that this can make plugins interfere with one another. The ones in question are upm_img_popper, upm_file_packets and hpw_admincss. I haven’t had the time to sit down and figure out the “proper” way to do this. I’ll post back here with whatever I can find.
Offline
#3 2005-10-08 20:38:38
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: Admin Plugin -- Edit Admin Screen
Okay, go ahead and use the output buffer just as you did.
Other plugin developers: if you have your plugin returning JavaScript or CSS as a linked file, be sure and tell output buffering to go away, by putting this before it:
while (@ob_end_clean());
‘scuse me while I go fix my plugins.
Offline