Forums / Developer / Passing Variables between different views within a module

Passing Variables between different views within a module

Author Message

Daniel Scheiner

Sunday 23 April 2006 5:55:11 am

Hi!

I'm new to ezP so please forgive any questions that might turn out to be stupid or self-explanatory. =)

I'm trying to create my first module.
I have 2 PHP-files (guess you call them views) in my ezmymodul-folder.
The first file/view -let's call it view1.php- <b>will be the first to be called from another server and that server will pass some POST-Variables to my view1.php</b>.

So:
I extract the POST-vars with the help of eZHTTPTool in my view1.php:

$http =& eZHTTPTool::instance();
if ( $http->hasPostVariable( "keyword" ) )
    $Keyword = $http->postVariable( "keyword" );

Now I want to pass this $Keyword - Variable to my second view, view2.php.
But here's where I stumble...
1) How do I pass this Variable to my view2.php?
2) How do I access this Variable in view2.php?
3) Do I have to declare some Params in module.php for it to work?

I would really appreciate any help on this subject!

Thanks!

Daniel

Präßler Sven

Monday 24 April 2006 1:44:51 am

Yes define a param in the Module.php file for view2.

$ViewList['view2'] = array(
	'script' 	=> 	'view2.php',
	'params'		=>	array('keyword')
);

1. Pass the variable with the url like:

www.mysite.de/intranet/mymodule/view2/myvariable

2.Access the variable by using:

$view2Keyword = $Params['keyword'];

Nabil Alimi

Wednesday 26 April 2006 6:43:22 am

You can also use session vars depending on what your aim is.

My blog : http://www.starnab.com/ezpublish / http://www.starnab.com/ / http://www.assiki-consulting.com
eZ Publish Freelance developper. Feel free to contact me +33 674 367 057
nabil at assiki d0t fr