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

TOPIC:

How to pass variables between two pages (layouts)? 13 Feb 2013 08:08 #6719

  • levi
  • levi's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 9
  • Thank you received: 1
Great application :cheer:

How can I pass a variable between to pages (layouts) that are based on two different tables?

I have two tables: "Companies" and "Departments".
One Company can have many Departments.

First I register a Company. I use several layouts to do this, using the "reuse" with "filter_company" to pass the Businessnumber from layout to layout. This works fine, and the company is saved in the database.

The next thing is to add one or more departments to the company. When I still have the company information in the layout, I use "reuse" with "filter_company" to try to pass the Businessnumber from the layout (based on Company) to a new layout (based on Department) so that I can choose which company I will add a new department to. This does not work. The variable Businessnumber is not passed.

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

Last edit: by levi. Reason: Updated spelling in Subject

Re: How to pass variables between to pages (layouts)? 13 Feb 2013 08:29 #6721

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195
hi There and welcome!

I think that this is a really good place to start. It's a great tutorial by @BTB300 on customising redirects: www.j-cook.pro/forum/33-developper-resso...-work-with-redirects

+ The tutorial/example component available here: www.j-cook.pro/docs/tutorials

Hope they help but don't hesitate to ask another question if anything is unclear!

Gez
Need help with your Cook/Joomla Project? . PM me to find out what I can help with. NO time wasters please!!!
The following user(s) said Thank You: levi

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

Re: How to pass variables between to pages (layouts)? 13 Feb 2013 08:30 #6723

  • levi
  • levi's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 9
  • Thank you received: 1
Tx. I will look at it :-)
The following user(s) said Thank You: JoomGuy

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

Re: How to pass variables between to pages (layouts)? 14 Feb 2013 07:38 #6738

  • levi
  • levi's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 9
  • Thank you received: 1
Hi,

I have now been looking at it and testing a lot of different options... but with no luck so far :(

I have now taken screenshots of everything and hoping someone feels for me :-) so I can come some further...

Databases:



Sandbox:









Layout:



(save & new)



The site:








Code from company.php:
public function save()
	{
		CkJSession::checkToken() or CkJSession::checkToken('get') or jexit(JText::_('JINVALID_TOKEN'));
		//Check the ACLs
		$model = $this->getModel();
		$item = $model->getItem();
		$result = false;
		if ($model->canEdit($item, true))
		{
			$result = parent::save();
			//Catch the initializated JModel trough postSaveHook()
			$model = $this->model;			
		}
		else
			JError::raiseWarning( 403, JText::sprintf('ACL_UNAUTORIZED_TASK', JText::_('SSL_JTOOLBAR_SAVE')) );

		//Catch the initializated JModel trough postSaveHook()
		$model = $this->model;

		//Define the redirections
		switch($this->getLayout() .'.'. $this->getTask())
		{
					case 'registerfirma.apply':
						$this->applyRedirection($result, array(
							'com_ssl.company.registerfirma',
							'com_ssl.company.dummyregistrerfirrma'
						), array(
							'cid[]' => $model->getState('company.id'),
							'filter_company' => $model->getState('company.id')
						));
						break;

					case 'dummyregistrerfirrma.save':
						$this->applyRedirection($result, array(
							'com_ssl.company.dummyregistrerfirrma',
							'com_ssl.department.leggtilavdeling'
						), array(
							'cid[]' => null,
							'filter_company' => $model->getState('company.id')
						));
						break;
		}
	}


}


Code from department.php:
public function save()
	{
		CkJSession::checkToken() or CkJSession::checkToken('get') or jexit(JText::_('JINVALID_TOKEN'));
		//Check the ACLs
		$model = $this->getModel();
		$item = $model->getItem();
		$result = false;
		if ($model->canEdit($item, true))
		{
			$result = parent::save();
			//Catch the initializated JModel trough postSaveHook()
			$model = $this->model;			
		}
		else
			JError::raiseWarning( 403, JText::sprintf('ACL_UNAUTORIZED_TASK', JText::_('SSL_JTOOLBAR_SAVE')) );

		//Catch the initializated JModel trough postSaveHook()
		$model = $this->model;

		//Define the redirections
		switch($this->getLayout() .'.'. $this->getTask())
		{
					case 'leggtilavdeling.save':
						$this->applyRedirection($result, array(
							'com_ssl.department.leggtilavdeling',
							'com_ssl.departements.default'
						), array(
							'cid[]' => null,
							'filter_company' => $model->getState('department.id')
						));
						break;

					case 'leggtilavdeling.save2new':
						$this->applyRedirection($result, array(
							'com_ssl.department.leggtilavdeling',
							'com_ssl.department.leggtilavdeling'
						), array(
							'cid[]' => null,
							'filter_company' => $model->getState('department.id')
						));
						break;
		}
	}


}


How should the company.php and department.php look like to for the Businessnumber > ID combobox to show all companies that have been registered, so that I can choose one of them and add a department to it using Save & new (to add several departments)?

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

Last edit: by levi. Reason: Increase size of images, again

Re: How to pass variables between to pages (layouts)? 14 Feb 2013 10:27 #6746

  • levi
  • levi's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 9
  • Thank you received: 1
Anyone?

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

Re: How to pass variables between to pages (layouts)? 15 Feb 2013 15:48 #6770

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195
Hi @levi,

Sorry I've not had time to come back to this until now!

OK, from looking at your screenshots:
In your DUMMY Register Firma form, you have a reuse properties set to redirect to your Legg Til Avdeling form, referencing the a field that should exist called "company" where you have filter_company. Instead, try changing that value to filter_businessnumber.

The reuse feature will always pass the newly created item's ID into the field specified after 'filter_'.

Hope it helps!

Gez
Need help with your Cook/Joomla Project? . PM me to find out what I can help with. NO time wasters please!!!

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

Re: How to pass variables between to pages (layouts)? 16 Feb 2013 20:23 #6786

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195
Did that help?
Need help with your Cook/Joomla Project? . PM me to find out what I can help with. NO time wasters please!!!

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

  • Page:
  • 1
Time to create page: 0.074 seconds

  Excellent Tool ! This tool will save you a lot of time writing the same old structure. I've used others but this is really nice for a quick start. Makes a 3 hour task a 15 minute one. Thanks for this extension
dickrundell (JED)
         

Get Started