Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2006-06-21 12:48:20

net-carver
Archived Plugin Author
Registered: 2006-03-08
Posts: 1,648

Modified Plugin Compiler

After a head-scratching morning, I decided I just had to modify the plugin compiler that Zem originally wrote.

Why?

Yesterday I added some admin-side processing to one of my existing plugins. As usual, I did all my development in the plugin cache directory until I was satisfied with the results, everything was working. I then compiled the plugin, installed and activated it. No problem. However, I got some unexpected behaviour when I went to the extensions tab and looked for my plugin’s output. Zip, nothing, tiada!

After a lot of digging, it turned out to be the simplest mistake I could have made—and something the compiler could have caught: in the plugin’s file I had forgotten to mark the plugin as type=1 to show it as an admin plugin. But when you run from the cache directory, this setting is bypassed and your plugin is loaded in the admin interface and the client interface. Doh!

(Okay, for all you old hands this wouldn’t really be a problem. But for newbies and relatively new plugin authors, this could be problmtatic.)

So now I present to you a new version of the compiler that checks to see if the declared type of a plugin actually matches what it tries to do. If it is not an admin plugin but tries to check if txpinterface == 'admin' (or vice-versa) then the compiler will halt and suggest you adjust the plugin’s type.

Additionally

This version of the compiler also adds a special CSS section to the plugin source file. Unlike the Help section, the CSS section does not get put through the textile mill. So you can confidently add style information into this part of the file without it getting chewed on.

Please Note: Be sure to make the rules specific to your own help section so that the rest of the admin interface isn’t mucked up by your beautiful styling; the example plugin shows you how to do it.

Grab it here.

Please feedback here with any ideas, bugs or other comments.

Last edited by net-carver (2006-06-21 13:17:13)


Steve

Offline

#2 2006-06-22 01:42:20

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

Re: Modified Plugin Compiler

You’ve got it checking for txpinterface and ==, which isn’t only used for an admin value.

Last edited by Mary (2006-06-22 01:42:40)

Offline

#3 2006-06-22 02:21:22

net-carver
Archived Plugin Author
Registered: 2006-03-08
Posts: 1,648

Re: Modified Plugin Compiler

Hi Mary,

I know that txpinterface is used for others (public, css etc) but I thought I had it doing a simple check for lines that contain three things…

  1. ‘@txpinterface’
  2. ‘==’
  3. ‘admin’

If all three are present in one line of a type 0 plugin it doesn’t output the encoded body of the compiled plugin.

Using a regular expression would probably be a better bet though.

Thanks :)

Last edited by net-carver (2006-06-24 15:54:58)


Steve

Offline

Board footer

Powered by FluxBB