Forums / Developer / pass variable from php to template

pass variable from php to template

Author Message

Dhaval Patel

Monday 17 December 2007 9:12:34 pm

hello

i have created one table.

and one template operator to fetch data from that table.

now i m making search template.

i can post the form and i m getting all the selected values to the action.php file.

now i want to run the query in action.php file and send the result to the template file in which i can show the search result.

please help me.

thank you very much

With Best Regards,

Dhaval Patel
Team Leader - iNETProcess(I) Pvt. LTD.
dhaval.patel@inetprocess.com
Ph No: +91 79 65 12 35 00
http://www.inetprocess.co.in

Piotrek Karaś

Monday 17 December 2007 9:38:59 pm

In PHP (this is PHP5 -> eZ4):

$tpl = templateInit();
$tpl->setVariable( 'custom_variable_name', 'custom_value' );

Then in templates you use:

{$custom_variable_name}

Hope this helps ;)

--
Company: mediaSELF Sp. z o.o., http://www.mediaself.pl
eZ references: http://ez.no/partners/worldwide_partners/mediaself
eZ certified developer: http://ez.no/certification/verify/272585
eZ blog: http://ez.ryba.eu

Dhaval Patel

Monday 17 December 2007 9:58:22 pm

hi,

thanks for replying

but its not working .

i am using ez10.

it gave me error that templateInit() call to undefined function.

then i include 'kernel/common/template.php'.

now no error. but result is also not in template.

I m using

$module->redirectTo( '/content/view/full/' . $nodeID);

at last.

please reply me.

With Best Regards,

Dhaval Patel
Team Leader - iNETProcess(I) Pvt. LTD.
dhaval.patel@inetprocess.com
Ph No: +91 79 65 12 35 00
http://www.inetprocess.co.in

Piotrek Karaś

Tuesday 18 December 2007 12:08:20 am

Proper PHP4 notation would be something like this:

include_once('kernel/common/template.php');
$tpl =& templateInit();

If you redirect to another location, then there's no template do be displayed. You could pass it in the URL as unordered parameters.

--
Company: mediaSELF Sp. z o.o., http://www.mediaself.pl
eZ references: http://ez.no/partners/worldwide_partners/mediaself
eZ certified developer: http://ez.no/certification/verify/272585
eZ blog: http://ez.ryba.eu

Nicolas Lescure

Tuesday 18 December 2007 12:20:08 am

Hi,

You don't have to use a redirection in a template operator.

Try this :

function modify(&$tpl, &$operatorName, &$operatorParameters, &$rootNamespace, &$currentNamespace, &$operatorValue, &$namedParameters) {	
	switch ($operatorName) {		
			case 'tempalte_operator_name':
				$operatorValue = 'the content you want in your template';
				break;			
		}	
	}

You can also download other extensions to help you : http://ez.no/developer/contribs/template_plugins

Piotrek Karaś

Tuesday 18 December 2007 12:30:07 am

I thought Dhaval was talking about custom module view. My bad ;)

--
Company: mediaSELF Sp. z o.o., http://www.mediaself.pl
eZ references: http://ez.no/partners/worldwide_partners/mediaself
eZ certified developer: http://ez.no/certification/verify/272585
eZ blog: http://ez.ryba.eu