Page 1 of 1
PHP counter plugin?
Posted: Sat Jul 31, 2004 12:44 am
by robintw
Hi,
I use a php based counter on my website that requires the following code to display a count on a webpage:
<?php
require "/srv/www/htdocs/COUNTER/phpcounter.php
?>
Is there anyway to work this into a plugin (I'm not too brilliant at php programming)?
Or is there a way to use it in the HTML snippet plugin (it wouldn't work for me).
Thanks in advance
Robin
Posted: Sun Aug 01, 2004 6:41 pm
by houndbee
1. Create a folder called serendipity_plugin_pluginname in the plugins/ folder.
2. Create a file called serendipity_plugin_pluginname.php within the folder you created in Step 1.
3. Add this code to the file you created in Step 2.
Code: Select all
<?php
class serendipity_plugin_pluginname extends serendipity_plugin {
function introspect(&$propbag)
{
$propbag->add('name', 'Plugin Name');
$propbag->add('description', 'Plugin Description');
}
function generate_content(&$title)
{
$title = "Plugin Title";
require ("/path/to/file");
}
}
?>
NOTE: Make sure you change all instances of
pluginname with the actual name you want for your plugin.
Posted: Thu Aug 25, 2005 3:36 am
by Guest
houndbee wrote:1. Create a folder called serendipity_plugin_
pluginname in the plugins/ folder.
2. Create a file called serendipity_plugin_
pluginname.php within the folder you created in Step 1.
3. Add this code to the file you created in Step 2.
Code: Select all
<?php
class serendipity_plugin_[color=red]pluginname[/color] extends serendipity_plugin {
function introspect(&$propbag)
{
$propbag->add('name', '[color=red]Plugin Name[/color]');
$propbag->add('description', 'Plugin Description');
}
function generate_content(&$title)
{
$title = "[color=red]Plugin Title[/color]";
require ("[color=red]/path/to/file[/color]");
}
}
?>
NOTE: Make sure you change all instances of
pluginname with the actual name you want for your plugin.
Is it correct that I have to change all things that I marked red? What do I have to fill in for /path/to/file ?
Posted: Thu Aug 25, 2005 7:02 pm
by garvinhicking
Yes, those places are right.
Replace /path/to/file with the location of the PHP script you want to embed. Like /www/htdocs/myhost/counter.php or so.
Also note that this posting was made in 2004 - now we already have a generic plugin called "serendipity_event_externalphp" which allows to include a PHP file with a simple configuration item of the plugin. That plugin is available in our plugin repository on CVS/spartacus.
Regards
Garvin