Hi, i need to build in the checkbox in the post message form, how can i make it with my plugin ?
Thanks
How to build in checkbox into the form?
-
loncaster_ukraine
- Regular
- Posts: 5
- Joined: Fri Jul 14, 2006 10:25 am
-
garvinhicking
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Re: How to build in checkbox into the form?
Hi!
You can hook into the 'backend_display' event, like the serendipity_event_entryproperties plugin does for example.
If you tell us more of what you want to do, I might be able to help you even more.
Best regards,
Garvin
You can hook into the 'backend_display' event, like the serendipity_event_entryproperties plugin does for example.
If you tell us more of what you want to do, I might be able to help you even more.
Best 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/
# 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/
-
loncaster_ukraine
- Regular
- Posts: 5
- Joined: Fri Jul 14, 2006 10:25 am
Re: How to build in checkbox into the form?
Well, after the posting new message plugin must check if the checkbox in the form was checked ON and then do something with the post content.garvinhicking wrote:Hi!
You can hook into the 'backend_display' event, like the serendipity_event_entryproperties plugin does for example.
If you tell us more of what you want to do, I might be able to help you even more.
Best regards,
Garvin
By the way, i wanted to ask something: in the WordPress blog the is a hook action "publish post" that executes when the post has been already stored in the database. Does Serendipity have something like this? (It must executes ONLY when the content is stored in DB).
P.S.
sorry for my pure english, but itsn't my native language ..
Thanks for the answers.
-
garvinhicking
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Re: How to build in checkbox into the form?
Hi!
Yes, you can do that. You should use a plugin like this:
The most important thing is the "backend_publish" event hook, there you can execute PHP you want to let happen when you save an entry.
Best regards,
Garvin
Yes, you can do that. You should use a plugin like this:
Code: Select all
<?php
class serendipity_event_mycheckbox extends serendipity_event
{
var $title = 'My Checkbox';
function introspect(&$propbag)
{
global $serendipity;
$propbag->add('name', 'My checkbox');
$propbag->add('author', 'Garvin Hicking');
$propbag->add('version', '0.1');
$propbag->add('requirements', array(
'serendipity' => '0.8',
'smarty' => '2.6.7',
'php' => '4.1.0'
));
$propbag->add('event_hooks', array(
'backend_publish' => true,
'backend_display' => true,
));
$propbag->add('groups', array('BACKEND_EDITOR'));
}
function generate_content(&$title) {
$title = $this->title;
}
function event_hook($event, &$bag, &$eventData, $addData = null) {
global $serendipity;
$hooks = &$bag->get('event_hooks');
if (isset($hooks[$event])) {
switch($event) {
case 'backend_display':
?>
<fieldset style="margin: 5px">
<legend>My Checkbox</legend>
<input type="checkbox" name="serendipity[mycheckbox]" id="mycheckbox" value="true" />
<label title="My Checkbox" for="mycheckbox"> Check me! </label><br />
</fieldset>
<?php
return true;
break;
case 'backend_publish':
if (isset($serendipity['POST']['mycheckbox'])) {
// Perform your action here that should be executed when an entry is published!
}
return true;
break;
}
} else {
return false;
}
}
}
Best 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/
# 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/
-
loncaster_ukraine
- Regular
- Posts: 5
- Joined: Fri Jul 14, 2006 10:25 am
-
garvinhicking
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Hi!
Where do you want to print that, and "when"?
Regards,
Garvin
Where do you want to print that, and "when"?
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/
# 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/
-
loncaster_ukraine
- Regular
- Posts: 5
- Joined: Fri Jul 14, 2006 10:25 am
see the code:garvinhicking wrote:Hi!
Where do you want to print that, and "when"?
Regards,
Garvin
Code: Select all
case 'backend_publish':
if (isset($serendipity['POST']['mycheckbox'])) {
// My text here
}
-
garvinhicking
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Hi!
Ah, you should just check that. The place where it appears is a simple text box, it is formatted with default HTML. Just echo your text and have a look.
Best regards,
Garvin
Ah, you should just check that. The place where it appears is a simple text box, it is formatted with default HTML. Just echo your text and have a look.
Best 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/
# 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/
-
loncaster_ukraine
- Regular
- Posts: 5
- Joined: Fri Jul 14, 2006 10:25 am
And can I print it without textbox, as in a new page ?garvinhicking wrote:Hi!
Ah, you should just check that. The place where it appears is a simple text box, it is formatted with default HTML. Just echo your text and have a look.
Best regards,
Garvin
By the way, I can't get acces for my checkbox (((
var_dump($serendipity['POST']);
Code: Select all
array(15) { ["action"]=> string(5) "admin" ["adminModule"]=> string(7) "entries" ["adminAction"]=> string(4) "save" ["id"]=> string(0) "" ["timestamp"]=> string(10) "1153149985" ["preview"]=> string(5) "false" ["token"]=> string(32) "629ece84ce4791cbe160c4a7c3498fa0" ["title"]=> string(0) "" ["isdraft"]=> string(5) "false" ["chk_timestamp"]=> string(10) "1153149985" ["new_timestamp"]=> string(16) "2006-07-17 18:26" ["categories"]=> array(1) { [0]=> string(1) "0" } ["body"]=> string(5) "hello" ["allow_comments"]=> string(4) "true" ["extended"]=> string(0) "" }