Guestbook Plugin V: 1.2

Creating and modifying plugins.
Post Reply
boelkstoff
Regular
Posts: 19
Joined: Wed Feb 02, 2005 8:46 pm

Guestbook Plugin V: 1.2

Post by boelkstoff »

Hello.
Since no guestbook plugin is available, i decided to write my own plugin.
I have tested it in the alpha version 0.8.
The basic is done, it would be nice if someone could help out with the design, because I am not a good webdesigner :-)
Also testing would be good.

Code: Select all

removed because old version! newest version in cvs
Last edited by boelkstoff on Fri Feb 11, 2005 4:31 pm, edited 3 times in total.
boelkstoff
Regular
Posts: 19
Joined: Wed Feb 02, 2005 8:46 pm

Post by boelkstoff »

One big error is still in.

After saving an entry it is saved twice and I dont know why.

Can somebody help me??
I could uncomment the session-lock. But that means that people can only write once into the guestbook and I dont wont that.

HELP NEEDED!!

Phil
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Thanks for contributing, this looks like a nice plugin. Would you like to contribute this to CVS? You would just need to clean up some codestyle issues (right indentation) and then you could maintain it there, if you like. (If yes, send me a mail with your SourceForge.net username and I will setup the CVS karma for you)

About the double insert: It seems to be you are calling $this->show() multiple times, so the "insert" action is called more than once.

Currently I am on very limited time so I can't look into it at the moment. I'll try to do that the next days, if you can't fix it by yourself already.

Looking forward to putting your plugin in our repository! :)

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/
boelkstoff
Regular
Posts: 19
Joined: Wed Feb 02, 2005 8:46 pm

Post by boelkstoff »

Hello Garvin,

yes I can contribute this to CVS, but not at the moment, because everything is still beta.
I also want a better design, before I put it into cvs.

To be honest I did not wrote the event_hook funktion. I copied it from another event plugin. I have no idea what is going on in this section, since there is no good doku for that.

Can anybody tell me what the event_hook function is doing here exactly?

Thank you
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi boelkstuff!

Okay, if you get it in "out-of-beta" state, please just contact me and I'd really like to put it into CVS!

About the event hooks: Have you read http://www.s9y.org/43.html#A30 ? I think it'S described there...the short summary is this:

When an event (like 'frontend_display') is triggered within the Serendipity stuff, all plugins are cycled and be checked if they want to perform actions on that trigger. If they do, the event_hook() method is executed. It gets passed the event hook name and input Data: $eventData and $addData. What is in those arrays always depends on the event type that is executed. 'Frontend_display' for example contains the $entry array as $eventData. $eventData is passed by reference and its data can be modified, while $addData contains additional data which cannot be modified.

Inside the event_hook method, the plugin can modify data as it likes, and after execution the usual Serendipity workflow continues.

HTH,
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/
boelkstoff
Regular
Posts: 19
Joined: Wed Feb 02, 2005 8:46 pm

Post by boelkstoff »

hello garvin,

ok think I get an idea what the hooks are doing.

But I still have the problem with the double entries.
I dont know what I am doing wrong.
Maybe one developer can take a look at it.


Thanks
Phil
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Phil,

maybe you can add some debugging on your own. I suppose that the generate_content() method is called twice.

Just create something like this at the beginning of that method:

Code: Select all

$fp = fopen('debug.log', 'a');
fwrite($fp, "Plugin method generate_content() has been called. Input values are: \n" . print_r(func_get_args(), true) .  "\n);
fclose($fp);
Then you create the page and look into your debug.log logfile and see why/when the method was called twice. Maybe some plugin introspection hooks call 'generate_content' earlier on...

I'd dore more debugging for you, but as I said I'm a bit short of time for that :(

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/
boelkstoff
Regular
Posts: 19
Joined: Wed Feb 02, 2005 8:46 pm

Post by boelkstoff »

WOW,
I insert your code and modified it.
I did not use the print_r(func_get_args() funktion I just used the tim() funktio n.
And it looks like the funktion is called 4x when I do an insert.

Maybe some other developer can help me out here PLEASE.

Thanks
Phil
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Okay, I looked into it.

You need to put your main code outside of generate_content() and inside its own method.

Because Serendipity executes the generate_content() method when querying for the plugin title.

Inside generate_content() for Event plugins you should only do stuff to the $title variable that is needed to get the title. Put everything else into a seperate method which is only called by your $this->show() code.

Then it will only be called once. Actually the static page plugin does it wrong as well, but there it's not doing evil because it's only echoing stuff and not doing database inserts.

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/
boelkstoff
Regular
Posts: 19
Joined: Wed Feb 02, 2005 8:46 pm

New Version 1.1

Post by boelkstoff »

Thanks that solved the problem.
I still dont know how to set the title of the html page from my plugin.
Solved that problem now (version 1.101 )!

But I worked today on the plugin:
here now the featurs
  • - integrate in the s9y style (like comments)
    - new .error style for error messages
    - session lock (one entry per session)
    - time look (one entry per time, e.g. one entry every 10sec
    - same url as other staticpages
    - custom number of entries per page
    - for use in 0.8 and only testet in an alpha version of 0.8 !!!
So here is the code and YES you can put it into CVS now.

Code: Select all

removed newest version in CVS
Last edited by boelkstoff on Fri Feb 11, 2005 4:32 pm, edited 1 time in total.
boelkstoff
Regular
Posts: 19
Joined: Wed Feb 02, 2005 8:46 pm

Post by boelkstoff »

Post in my guestbook (with Email) and you will get email when a new version is out :D
Trench
Regular
Posts: 85
Joined: Fri Nov 05, 2004 11:38 am

Post by Trench »

Supid question time.

What is the URL to my guestbook suppoed to be.
SILU
Regular
Posts: 56
Joined: Sat Dec 04, 2004 10:28 pm
Location: Vienna / Austria
Contact:

Post by SILU »

Hi, i want to use the guestbook, downloaded the php-file from CVS and put into the directory plugins/serendipity_event_guestbook/serendipity_event_guestbook.php - but then i get an error @ the admin-center @ plugins:
Parse error: parse error in /var/www/web96/html/serendipity/plugins/serendipity_event_guestbook/serendipity_event_guestbook.php on line 37
Fehler: serendipity_event_guestbook
What to do ? thx, SILU
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

SILU, it seems you did not download the plugin correctly. Check it out from CVS or download it properly, or download the full mirror padditional_plugins file at http://www.netmirror.org/mirror/serendipity/.

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