Tutorial for plugin ?

By Djulia - February 3, 2010

Hi,

I would like to create a simple function that I would like to activate or deactivate in the section plugins ?

There would be a tutorial to explain how to create (to activate) a plugin?

Thanks for the feedback!

Djulia

Re: [Djulia] Tutorial for plugin ?

By Dave - February 4, 2010

Hi Djulia,

I can write something up. Do you just want to automatically load your plugin or do you want to use one of the plugin hooks? Or, put another way, what do you want your plugin to do?

For the most part you can just create a php file in the /plugins/ folder with this header:

<?php


function yourfunction() {
...
}

?>


Once you do that you'll be able to see it and "activate" it in the plugins menu. Once activated it will be loaded by admin.php and any of your viewer pages.

The "Requires at least" line refers to CMSB versions. You can't activate a plugin unless you have at least that version.

Hope that helps! Let me know any additional details you need.
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Tutorial for plugin ?

By Djulia - February 4, 2010

Hi Dave,

I wrote my plugin!

But, I did not really understand the use of addFilter.
That seems to be an important parameter.
It is the insertion point ?

Thanks to risk you in the explanations!

Djulia

Below my plugin, it will be perhaps useful for other users!
He alerts by email the admin if a user connects himself.

Attachments:

alertadminlogin.php 2K

Re: [Djulia] Tutorial for plugin ?

By Dave - February 4, 2010

Hi Djulia,

Looks good. I added this semicolon to make it work for me:
. "http://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}\n";

addFilter() and addAction() are almost the same but addFilter() must always return something. It's used to modify a value (such as the footer text), where-as addAction() just runs some code.

Let me know if you have any other questions about how everything works! :)
Dave Edis - Senior Developer
interactivetools.com

Re: [Djulia] Tutorial for plugin ?

By Dave - February 6, 2010

Also, for v2.03 (in development) I've updated it to call session_destroy() on logout. That should allow you to make you code simpler for future plugins (since the counter will automatically get reset when a new session is created).
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Tutorial for plugin ?

By Djulia - February 11, 2010 - edited: February 11, 2010

Thanks Dave for the update! :)

That functions perfectly with version 2.03.

Djulia

Attachments:

alertadminlogin_001.php 2K

Re: [Dave] Tutorial for plugin ?

By Djulia - April 2, 2010

Hi Dave,

The post of Terry motivated me to improve a plugin that I had written.
It sends an email notification when a record is added or modified ...

CMSB impresses me each day by its flexibility!

But, I still block with the use of css.

Djulia

Attachments:

alertsavedrecord_001.php 3K

Re: [Djulia] Tutorial for plugin ?

By flamerz - April 2, 2010

wow.. this one is a must have.

good job.

Re: [Djulia] Tutorial for plugin ?

By hvbuilder - April 10, 2010

Hello,

I upgraded to version 2.03 and installed your plugin, but I do not receive an email when a record is added or changed. Is there something else I need to do?

Thanks,

James