Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2009-06-18 11:00:06
- FireFusion
- Member
- Registered: 2005-05-10
- Posts: 698
Need help writing a super simple small plugin
I want to make a plugin that creates a new tab under the content tab and displays some content in that tab. I’m fine with handcoding the HTML i want into to the plugin.
I just need to code for…- Creating a new admin tab under the content tab (Allowing all priv levels to access it)
- And to echo some HTML of my choice
Last edited by FireFusion (2009-06-18 11:00:28)
Offline
Re: Need help writing a super simple small plugin
FireFusion wrote:
Take a look at any plugin that creates a tab for inspiration. But in short:
if (@txpinterface == 'admin') {
// Set privs to all levels
add_privs('your_tab_ref', '1,2,3,4,5,6');
// Create the tab under 'content'
register_tab("content", 'your_tab_ref', 'My New Tab');
// Tell TXP what to do to render the tab contents
register_callback('your_plugin_function', 'your_tab_ref');
}
function your_plugin_function($event, $step) {
pagetop('My Page');
// echo your HTML here and it will appear on your new tab
echo 'Hello world';
}
That’s pretty much it.
EDIT: Fixed stupidity
Last edited by Bloke (2009-06-18 11:31:50)
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline
#3 2009-06-18 11:34:02
- FireFusion
- Member
- Registered: 2005-05-10
- Posts: 698
Re: Need help writing a super simple small plugin
Thanks Bloke!
It shows this error when you go to the tab.
Warning: Missing argument 1 for pagetop(), called in C:\wamp\www\txpdev.local\textpattern\lib\txplib_misc.php(580) : eval()'d code on line 11 and defined in C:\wamp\www\txpdev.local\textpattern\lib\txplib_head.php on line 9
I’m pretty useless with PHP. I guess i was meant to put something in this part?
function your_plugin_function($event, $step) {
pagetop();
Offline
#4 2009-06-18 11:42:30
- FireFusion
- Member
- Registered: 2005-05-10
- Posts: 698
Re: Need help writing a super simple small plugin
Excellent!
Thanks Bloke for the fix.
Offline
Re: Need help writing a super simple small plugin
FireFusion wrote:
It shows this error when you go to the tab.
Sorry, see edit above.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline