Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2007-04-27 16:05:24

gerhard
Plugin Author
From: London, UK
Registered: 2005-06-29
Posts: 409
Website

Add/remove admin tabs without hacking txplib_head.php

Hi, I was wondering what would the best way to add/remove admin tabs be? I really really don’t want to hack anything, just use register_callback() or something of the like to do the trick. I need to have custom top-level tabs for a certain type of users. I don’t think I can modify TXP user levels without hacking, or?

Cheers.

Offline

#2 2007-04-27 17:00:32

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: Add/remove admin tabs without hacking txplib_head.php

Maybe you could adapt this plugin to your needs?

Also if you only need to change the tab’s label, you can do so in the txp_lang table.

Offline

#3 2007-04-27 18:09:48

gerhard
Plugin Author
From: London, UK
Registered: 2005-06-29
Posts: 409
Website

Re: Add/remove admin tabs without hacking txplib_head.php

Yes, that’s a plugin that I will adapt for my needs, but what I need is a brand new tab, alongise Content, Presentation etc. (that’s why I mentioned top-level). Is there any way to do this apart from hacking txplib_head.php? The lower-levels tabs are not a problem, register_tab() takes care of it.

Another question would be why admin-side plugins don’t work if I use them in the scrips/plugins directory I specify in preferences? It’s darn annoying to code the plugin in one app and then having to paste it & save it in plugins tab before seeing the changes. Any ideas on this?

What about TXP user types? Any ideas on how to do this through a plugin? I need just 4 user types with totally different names than the default ones (for consistency purposes).

Oh Els, cheers for the tip on txp_lang table, I was already thinking about that ; ).

Offline

#4 2007-04-27 21:56:48

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: Add/remove admin tabs without hacking txplib_head.php

Another question would be why admin-side plugins don’t work if I use them in the scrips/plugins directory I specify in preferences?

I assume that’s for security reasons. Sorry I can’t answer your questions, you obviously know a lot more about this than I do. So I suppose you also know about Yura’s ied_plugin_composer :)

Offline

#5 2007-04-28 10:29:00

gerhard
Plugin Author
From: London, UK
Registered: 2005-06-29
Posts: 409
Website

Re: Add/remove admin tabs without hacking txplib_head.php

Els, cheers for getting back. Yes, that makes sense, pretty obvious why admin-side plugins aren’t allowed in the plugin cache dir.

Well, with Yuriy’s plugin, I don’t think I would be gaining much in my situation. All I have to do now is keep editing the file I have in the plugin cache dir and then just copy it across to my plugin’s edit window and hit save. So in real terms I have 3 more steps:

  • click plugin edit
  • paste code
  • click save

I know I am being pedantic here, but you know how us developers are – a lazy lazy lot : ). Having said that, if you do 500 changes by the time the plugin is fully finished (and this is a looooong plugin), 5 seconds per edit, you are already looking at 40 minutes of dead time… not to mention that it drives me bonkers to keep clicking and pasting and clicking again.

Anyways, I think I will just enable admin-side plugins in the cache directory and stop annoying you lot with these silly questions.

The coffee still hasn’t kicked in, this post might not make any sense at all :~~

Offline

#6 2007-04-28 12:03:45

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: Add/remove admin tabs without hacking txplib_head.php

gerhard wrote:

…but you know how us developers are – a lazy lazy lot : ).

No I didn’t know that, but you just made me realize that I’d make a good developer, since I’m really lazy ;)

I hope Mary or some other wise person will find this thread.

Offline

#7 2007-04-28 12:09:46

gerhard
Plugin Author
From: London, UK
Registered: 2005-06-29
Posts: 409
Website

Re: Add/remove admin tabs without hacking txplib_head.php

Good Pogrammers

The Rails lot is the laziest, most pragmatic of them all. If it isn’t DRY, it isn’t Rails : ))).

Offline

#8 2007-04-29 00:45:46

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: Add/remove admin tabs without hacking txplib_head.php

…what I need is a brand new tab, alongise Content, Presentation etc… Is there any way to do this apart from hacking txplib_head.php?

I’m afraid not. :/

What about TXP user types?

Ditto. Until we revamp the Privileges system (to actually being a real system), you’ll have to modify admin_config.php.

Another question would be why admin-side plugins don’t work if I use them in the scrips/plugins directory I specify in preferences?

I assume that’s for security reasons.

admin-side plugins are most definitely allowed in the plugin cache directory – thank god or I’d have torn my hair by now with several of my plugins – so if they aren’t working for you, something is definitely wrong.

The only security precaution taken is that no plugins of any kind are run on the plugins tab, so that if something goes awry you can still disable/remove the offending plugin.

If you want, you can email me a copy and I’ll see if I can find any problem(s) in the plugin itself.

Last edited by Mary (2008-04-05 05:25:22)

Offline

#9 2007-04-29 02:06:10

gerhard
Plugin Author
From: London, UK
Registered: 2005-06-29
Posts: 409
Website

Re: Add/remove admin tabs without hacking txplib_head.php

Mary, thank you for chipping in! Just sent you an e-mail. It’s sooo good to hear from a hot-head like you that it can’t be done. Now I am 100% that I’m not missing anything. Always thankful!

Offline

#10 2007-04-29 04:19:17

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: Add/remove admin tabs without hacking txplib_head.php

Got it. Works fine for me, so no worries there.

Does nothing show up at a url similar to this?
http://url/to/textpattern/index.php?event=realtor

Remember that you still need to manually add the top tab.

It occured to me that you could try working around hacking txplib_head.php by using an output buffer. Alternatively, you could simply create a 5th tab under Content, add the others under Content, and use the 5th as a sort of menu for the others.

You should also use the plugin template while actually developing the plugin. It will run exactly like a plain PHP file, can save on copy & paste later (and errors that can creep in when that is done), and can allow you to make use of plugins like tsw_help_display.

Offline

#11 2007-04-29 19:37:32

gerhard
Plugin Author
From: London, UK
Registered: 2005-06-29
Posts: 409
Website

Re: Add/remove admin tabs without hacking txplib_head.php

Mary, thank you for your reply!

Does nothing show up at a url similar to this? http://url/to/textpattern/index.php?event=realtor

Only if I have the plugin in the db, not if it is in scripts folder. This is what I get if I disable it in in the plugins tab but keep it in scripts

Remember that you still need to manually add the top tab.

Yes, this is that txplib_head hack…

It occured to me that you could try working around hacking txplib_head.php by using an output buffer.

ob_start() / ob_end() ? If I understand correctly how ob_ works, I would still have to add this somewhere in the file code (index.php maybe?).

Alternatively, you could simply create a 5th tab under Content, add the others under Content, and use the 5th as a sort of menu for the others.

Actually, there will be different type of users – different from TXPs default – and that new tab will show only for some of them. TXPs admin gets the full shebang, while these new users will get only this new tab. Again, “Content” wouldn’t be an appropriate name so maybe if I would be able to rename it through register_callback("txp_my_function", "txp_my_admin_page");. Hmmm, would that actually work?

You should also use the plugin template while actually developing the plugin. It will run exactly like a plain PHP file, can save on copy & paste later (and errors that can creep in when that is done), and can allow you to make use of plugins like tsw_help_display.

When I keep copy/paste across, I want to select it all (I would die if I would have to select portions of the code on each copy/paste!), the extra plugin template code would get in the way.

My admin-side plugin still doesn’t want to run from that dir at all. You have seen the screengrab from above… I am lost on this one. AND THERE IS NO BLOODY ERROR EITHER.

Offline

#12 2007-04-30 20:14:02

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: Add/remove admin tabs without hacking txplib_head.php

Try completely removing the plugin from the database.

If I understand correctly how ob_ works, I would still have to add this somewhere in the file code (index.php maybe?).

No, you can call it from a plugin. I’ve done it several times.

When I keep copy/paste across, I want to select it all (I would die if I would have to select portions of the code on each copy/paste!), the extra plugin template code would get in the way.

Wha? Why would you be copy & pasting at all?

Offline

Board footer

Powered by FluxBB