Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC:

Custom redirect after saving or cancelling a form 25 May 2015 22:45 #13183

  • MorganL
  • MorganL's Avatar Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
  • Posts: 438
  • Thank you received: 53
I have a view from a table item, for the sake of argument called 'table1'.

index.php?option=com_mycomponent&view=table1&cid[0]=1

I have created a link from this table which opens the item form of table2 i.e

index.php?option=com_mycomponent&view=table2&layout=addform

When I click SAVE and CLOSE or CANCEL, I go back to the GRID view for table2.. as expected

I need the page to actually go BACK to the view index.php?option=com_mycomponent&view=table1&cid[0]=1

How can I override this?
Morgan Leecy MCSE

Novell / Linux
PHP. MYSQL, Apache, node.js
Coldfusion, JQuery, HTML5
Joomla

Please Log in or Create an account to join the conversation.

Custom redirect after saving or cancelling a form 26 May 2015 20:08 #13184

Hi,

Fork the controller for view2 the item controller, not the items), change the "applyRedirection" in the save/cancel function to redirect to your table1
Check the controllers and I think it will be obvious for you. If not, I can provide example code.

edit: code added

Like I said: create a fork/controllers/table1.php, copy the function cancel() from the original controllers/table1.php and paste it into you fork.
Then change in fork like this (or similar, default might be another view in your case)
public function cancel()
{
	$this->_result = $result = parent::cancel();
	$model = $this->getModel();

	//Define the redirections
	switch($this->getLayout() .'.'. $this->getTask())
	{
		case 'table1.cancel':
			$this->applyRedirection($result, array(
				'stay',
				'com_mycomponent.table1.default'
			), array(
				'cid[]' => null
			));
			break;

		default:
			$this->applyRedirection($result, array(
				'stay',
				'com_mycomponent.table1.default'
			));
			break;
	}
}

Something like that should work (tried in my own component and works)

Please Log in or Create an account to join the conversation.

Last edit: by Romkabouter.
  • Page:
  • 1
Time to create page: 0.078 seconds

Awards for the best Joomla app. This product is gonna win an award for this amazing job. Cook Self Service is the the best application from all over the Joomla universe ! It brings Joomla to a professional level really advanced for developers. It is a real fun to develop with it. The ACL part and security checks implementation are just... so much hours saved. I can now concentrate myself more on the design part and the creative works. Thank you so much. Guys I offer you all my congratulation ! Keep up the works because Joomla is needing it to increase the quality of extensions availables on the JED. I also learned a lot because I can see how to code at the proper place and I found all my answers reading the forum.
lack_hanson (JED)
          

Get Started