Currently after I enter an entry, it stays on the page that says it's saved and remains in the admin section.
How would I be able to change this without hacking the serendipity code, can redirects be done in a plugin or is this the wrong way to go?
Id like to be able to redirect to the final post after saving completes
Regards,
Lee
Add entry then Redirect to view entry after save (how?)
-
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Re: Add entry then Redirect to view entry after save (how?)
Hi!
You could write a plugin that listens on the "backend_publish" hook for example, yes. How much do you know about the plugin API, does that information help you?
Regards,
Garvin
You could write a plugin that listens on the "backend_publish" hook for example, yes. How much do you know about the plugin API, does that information help you?
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/
Re: Add entry then Redirect to view entry after save (how?)
I had a look a freetag plugin to try and see what was going on with backend_publish but couldnt make sense of it.
I have yet to get my head round all the hooks n the like, but im sure i will get there, then i can start publishing plugins
I have yet to get my head round all the hooks n the like, but im sure i will get there, then i can start publishing plugins
-
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Re: Add entry then Redirect to view entry after save (how?)
Hi!
Okay, it's not really hard, here's an example for your case:
If you have more questions, feel free to ask
HTH,
Garvin
Okay, it's not really hard, here's an example for your case:
Code: Select all
<?php
class serendipity_event_bumpcomment extends serendipity_event {
var $title = 'Bump comments';
function introspect(&$propbag) {
global $serendipity;
$propbag->add('name', 'Bump Comments');
$propbag->add('description', '');
$propbag->add('stackable', false);
$propbag->add('author', 'Garvin Hicking');
$propbag->add('version', '1.0');
$propbag->add('requirements', array(
'serendipity' => '0.8',
'smarty' => '2.6.7',
'php' => '4.1.0'
));
$propbag->add('event_hooks', array(
'backend_publish' => true
));
}
function event_hook($event, &$bag, &$eventData, $addData = '') {
global $serendipity;
$hooks = &$bag->get('event_hooks');
if (isset($hooks[$event])) {
switch($event) {
case 'backend_publish':
header('Location: http://www.google.de/');
exit;
return true;
break;
}
}
}
}
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/
# 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/
Re: Add entry then Redirect to view entry after save (how?)
Thanks
So, you can stack them up like this?
So, you can stack them up like this?
Code: Select all
$hooks = &$bag->get('event_hooks');
if (isset($hooks[$event])) {
switch($event) {
case 'frontend_saveComment_finish':
serendipity_db_query("UPDATE {$serendipity['dbPrefix']}entries
SET timestamp = UNIX_TIMESTAMP(NOW())
WHERE id = '" . (int)$addData['comment_id'] . "'");
return true;
break;
case 'backend_publish':
header('Location: http://www.google.de/');
exit;
return true;
break;
-
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Re: Add entry then Redirect to view entry after save (how?)
Hi!
Yeah, you can do that! Just remember to also add frontend_saveComment_finish at the "introspect" method to the propbag where all event hooks that the plugin wants to use need to be shown.
HTH,
Garvin
Yeah, you can do that! Just remember to also add frontend_saveComment_finish at the "introspect" method to the propbag where all event hooks that the plugin wants to use need to be shown.
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/
# 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/
Re: Add entry then Redirect to view entry after save (how?)
Now you have lost me...garvinhicking wrote: Just remember to also add frontend_saveComment_finish at the "introspect" method to the propbag where all event hooks that the plugin wants to use need to be shown.
HTH,
Garvin
-
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Re: Add entry then Redirect to view entry after save (how?)
Hi!
You need to change this
You need to change this
Code: Select all
$propbag->add('event_hooks', array(
'backend_publish' => true
));
Code: Select all
$propbag->add('event_hooks', array(
'backend_publish' => true,
'frontend_saveComment_finish' => true
));
# 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/
Re: Add entry then Redirect to view entry after save (how?)
This sort of works...
However, the redirect is only showing in the frame below:
'Serendipity is now saving your entry, creating trackbacks and performing possible XML-RPC calls. This may take a while..'
I still see the add entry form below that with my populated text... and it doesnt redirect to the main blog page
However, the redirect is only showing in the frame below:
'Serendipity is now saving your entry, creating trackbacks and performing possible XML-RPC calls. This may take a while..'
I still see the add entry form below that with my populated text... and it doesnt redirect to the main blog page
-
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Re: Add entry then Redirect to view entry after save (how?)
Hi!
Hm, okay. I suppose instead of a redirect you then need javascript code that accesses the parent frame and redirects there...
Regards,
Garvin
Hm, okay. I suppose instead of a redirect you then need javascript code that accesses the parent frame and redirects there...
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/
Re: Add entry then Redirect to view entry after save (how?)
So i can redirect the frame as per above... but to a page that contains this...
Code: Select all
<script type="text/javascript">
setTimeout('Redirect()',4000);
function Redirect()
{
self.parent.location.href = 'http://localhost/serendipity/';
}
</script>