Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2004-12-03 12:15:10

1beb
Plugin Author
From: Canada, Ontario, Toronto
Registered: 2004-11-22
Posts: 169
Website

beb_codecolor...

I’m trying to make a dead simple plug-in, that takes the contents of a text file and pumps it out onto the screen in a formatted manner.

What seems to be happening is that things go missing when I move it into base64. It’s description and most of the code of the plugin itself are gone.

<code>
<?php

// plugin name must be url-friendly, with no spaces // please prepend the plugin name with a 3-letter developer identifier

$plugin[‘name’] = ‘beb_codecolor’;

$plugin[‘author’] = ‘Brandon Erik Bertelsen’;

$plugin[‘author_uri’] = ‘http://www.bertelsen.ca’;

$plugin[‘version’] = ‘0.0’;

// short description of the plugin

$plugin[‘description’] = ‘Outputs highlighted php code from a text file’;

// short helpfile (xhtml) – please be explicit in describing how the plugin // is called, and any parameters that may be edited by the site publisher

$plugin[‘help’] = ‘

<p>Save a text file to your server with the PHP code in it that you wish to highlight. Use</p> <ul><li><txp:beb_colorcode source=\“url of text file\”/></li></ul>

‘;

// The plugin code, as a string. NO PHP open/close tags please

$plugin[‘code’] = <<<eod

function beb_codecolor($atts) {echo highlight_string(file_get_contents(\”$source\”),true);}

eod;

$plugin[‘md5’] = md5( $plugin[‘code’] );

// to produce a copy of the plugin for distribution, load this file in a browser.

echo base64_encode(serialize($plugin));

?>
</code>

I can’t seem to get it to work… any suggestions?

Offline

#2 2004-12-04 23:49:36

zem
Developer Emeritus
From: Melbourne, Australia
Registered: 2004-04-08
Posts: 2,579

Re: beb_codecolor...

The beb_codecolor() function should return the output, not echo it.

You could try using the updated plugin template


Alex

Offline

#3 2004-12-05 00:16:32

1beb
Plugin Author
From: Canada, Ontario, Toronto
Registered: 2004-11-22
Posts: 169
Website

Re: beb_codecolor...

Hrmmm, that exact code works on another static page perfectly. I’ll try out the updated plugin template and post back

Offline

#4 2004-12-05 02:31:44

zem
Developer Emeritus
From: Melbourne, Australia
Registered: 2004-04-08
Posts: 2,579

Re: beb_codecolor...

> 1beb wrote:

> Hrmmm, that exact code works on another static page perfectly.

Plugins have to be written in a particular way.


Alex

Offline

#5 2004-12-05 07:14:32

1beb
Plugin Author
From: Canada, Ontario, Toronto
Registered: 2004-11-22
Posts: 169
Website

Re: beb_codecolor...

It’s ok, I’m just going to use a form for that specific entry… it works that way just fine.

Cheers Zem,

Offline

Board footer

Powered by FluxBB