Jump to content

How to pass php variable to other file


newcoder1010
 Share

Recommended Posts

Hi,

 

I am using drupal.

 

Template.tpl.php

 

I have a function

 

function bartik_preprocess_print(&$vars, $hook) { // Global node. $node = $vars['node']; $vars['price'] = field_view_value('node', $node, 'field_price', $node->field_price[$node->language][0]);  $vars['vehicleOption1'] = field_view_value('node', $node, 'field_vehicle_option_1', $node->field_vehicle_option_1[$node->language][0]); }

in print.tpl.php,

 

I have

 

print render($test); print render($vehicleOption1);

But I am only getting the one value and it is the value of $vehicleOption1

 

Can you please help as for how I can values from the both variables?

 

Thanks,

N

Link to comment
Share on other sites

Sorry, I don't know how they are related. All I can template.tpl.php and print.tpl.php in two different directories.

 

If I just have one variable in template.tpl.php file as

 $vars['price'] = field_view_value('node', $node, 'field_price', $node->field_price[$node->language][0]); 

I can see the value by writing the below code in print.tpl.php file

print render($price); 

I just need to know how I can declare the 2nd variable in the template.tpl.php file?

 

Thanks.

Link to comment
Share on other sites

  • 2 weeks later...

ok i'm using drupa 7 too

you must add a new $vars['test'] in the precess_print function

 

or maybe you can decalare any vaiables in template.php inside your_theme_preprocess_page function and call it in template/youtempate.tpl.php

 

that's the way that i use maybe you can find something better

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...