Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Click Save and get redirected to a different tab

When ur in Post.php and u click save. If a blog category was selected, it should redirect u to the blog tab and not the discussions tab.
how do i do that?

thanks

Comments

  • Look in Vanilla.Control.DiscussionForm.php

    I think you will want to attach to the PostSaveComment and PostSaveDiscussion delegates. Right after those delegates are some example PHP commands that direct the user to the last page of the comments or resulting discussion.

    Only suggestion would be to call $Context->Unload(); right before the die(); command, to close a little more cleanly out of the script.
  • edited April 2007
    Thanks Wally :)
    So doing $Context->Unload() will prevent this code from executing
    if ($ResultDiscussion) { // Saved successfully, so send back to the discussion $Suffix = CleanupString($this->Discussion->Name).'/'; header('location:'.GetUrl($this->Context->Configuration, 'comments.php', '', 'DiscussionID', $ResultDiscussion->DiscussionID, '', '', $Suffix)); die(); }
  • No, $Context->unload disconnects from the database and cleans up any objects that may be laying around, but the die() will be where you decide to stop execution.
  • edited April 2007
    thanks, just for reference for others who want the same thing
    if ('post.php' == $Context->SelfUrl) { function Redirect(&$DiscussionForm) { if ($DiscussionForm->Discussion->CategoryID == $DiscussionForm->Context->Configuration['BLOG_CATEGORY']) { header('location:'.GetUrl($DiscussionForm->Context->Configuration, 'extension.php', '', '', '', '', 'PostBackAction='.$DiscussionForm->Context->GetDefinition('Blog'))); die(); $Context->Unload(); } } $Context->AddToDelegate('DiscussionForm', 'PostSaveDiscussion', 'Redirect'); }
  • Looks great!

    Two last tips: there should be a space between the colon and the URL, and you are going to have to wrap a str_replace() (I had to do it in CommentLinks) around the GetUrl to replace any &'s (XHMTL valid) in the URL with standard & (HTTP redirection valid).
    Switch unload and die--unload will never get called because die stops execution first.
This discussion has been closed.