PHP counter plugin?

Creating and modifying plugins.
Post Reply
robintw
Regular
Posts: 10
Joined: Sat Jul 31, 2004 12:41 am

PHP counter plugin?

Post 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
houndbee
Regular
Posts: 18
Joined: Fri Apr 30, 2004 4:53 pm
Location: Bangalore, India
Contact:

Post 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.
Guest

Post 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 ?
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post 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
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Post Reply