Hi!
I upgraded to S9Y 1.1beta and have the problem that my counter-codes don't work anymore. I added them in Version 1.0 to the end of the index.php but that doesn't seem to work with 1.1.
Where can I add the counter-code now and where is the best place for non-S9Y php-code in general?
Best place to insert php code?
-
Harald Weingaertner
- Regular
- Posts: 474
- Joined: Mon Mar 27, 2006 12:32 am
-
garvinhicking
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Plus, you should tell us your counter code 
Try your template's config.inc.php file. Editing core serendipity files is always not so good. If your templates config.inc.php does not help, you will need to create an event plugin. That's what plugins are for, actually. For not needing to patch code.
Best regards,
Garvin
Try your template's config.inc.php file. Editing core serendipity files is always not so good. If your templates config.inc.php does not help, you will need to create an event plugin. That's what plugins are for, actually. For not needing to patch code.
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/
I think a plugin would be the best solution, because I wouldn't have to adapt the code after every S9Y-upgrade.
But: How? E.g. I have this code:
But: How? E.g. I have this code:
Code: Select all
<?php
$chCounter_visible = 0;
$chCounter_status = 'active';
include( '/home/www/doc/13460/blokey.de/www/chCounter/counter.php' );
?>-
garvinhicking
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Hi!
Yeah, you could do that with a plugin listening on the "frontend_configure" hook:
Yeah, you could do that with a plugin listening on the "frontend_configure" hook:
Code: Select all
<?php
class serendipity_event_counter extends serendipity_event {
function introspect(&$propbag) {
global $serendipity;
$propbag->add('name', 'counter');
$propbag->add('description', '');
$propbag->add('stackable', false);
$propbag->add('author', 'Garvin Hicking');
$propbag->add('version', '1.0');
$propbag->add('requirements', array(
'serendipity' => '0.8',
'php' => '4.1.0'
));
$propbag->add('event_hooks', array(
'frontend_configure' => true,
));
$propbag->add('groups', array('BACKEND_FEATURES'));
}
function event_hook($event, &$bag, &$eventData, $addData = null) {
global $serendipity;
$hooks = &$bag->get('event_hooks');
if (isset($hooks[$event])) {
switch($event) {
case 'frontend_configure':
$chCounter_visible = 0;
$chCounter_status = 'active';
include('/home/www/doc/13460/blokey.de/www/chCounter/counter.php');
return true;
break;
default:
return true;
break;
}
} else {
return false;
}
}
}
# 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/
-
garvinhicking
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Hi!
Uh, that code above is a plugin that you should save in your plugins/serendipity_event_counter/ directory as serendipity_event_counter.php and then install it through the s9y plugin interface.
It is actually completely unrelated to javascript...
Best regards,
Garvin
Uh, that code above is a plugin that you should save in your plugins/serendipity_event_counter/ directory as serendipity_event_counter.php and then install it through the s9y plugin interface.
It is actually completely unrelated to javascript...
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/
Hi Garvin!
When I use the above code as plugin then I get the following message in the top-lines of the backoffice:
The output on the front is the same as usual. I tried the same plugin-code (with renamed folder and adapted code) for another counter, which seems to work without problems. The warning doesn't seem to be connected to the second plugin, because it comes also when the second plugin is deactivated.
update:
Ups, the front output is also affected. Clicking links reproduces nearly the same message:
When I use the above code as plugin then I get the following message in the top-lines of the backoffice:
Code: Select all
Warning: Cannot modify header information - headers already sent by (output started at /home/www/doc/13460/blokey.de/www/chCounter/counter.php:1614) in /home/www/doc/13460/serendipity/serendipity_admin.php on line 11update:
Ups, the front output is also affected. Clicking links reproduces nearly the same message:
Code: Select all
Warning: Cannot modify header information - headers already sent by (output started at /home/www/doc/13460/blokey.de/www/chCounter/counter.php:1614) in /home/www/doc/13460/serendipity/exit.php on line 29
Warning: Cannot modify header information - headers already sent by (output started at /home/www/doc/13460/blokey.de/www/chCounter/counter.php:1614) in /home/www/doc/13460/serendipity/exit.php on line 30-
garvinhicking
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Hi!
Well, yes. I don't know anything about your counter, and your counter.php is now making the trouble. Why is it outputting anything? Of course I can only help you with s9y code, and not foreign counter code - I just gave you an example plugin of how to include a PHP script in a plugin.
The error tells you that counter.php outputs HTML code, but at this point serendipity does not allow HTML output.
Regards,
Garvin
Well, yes. I don't know anything about your counter, and your counter.php is now making the trouble. Why is it outputting anything? Of course I can only help you with s9y code, and not foreign counter code - I just gave you an example plugin of how to include a PHP script in a plugin.
The error tells you that counter.php outputs HTML code, but at this point serendipity does not allow HTML output.
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/