Passing php variable to template
#1
Question 
Hi!
      I've a problem with my hardware forum passing php variables to template, I want I'cant pass $width y $height

I'm using this plugin and I can effectively use PHP in templates so this should work:

<div style="float:right; display:inline-block; width: <?php echo $width; ?>px; height: <?php echo $height; ?>px; padding-left:10px; padding-right:10px; margin-left:10px; margin-right:10px; none repeat scroll 0% 0%;" >

But not! 

Echo works but print nothing!

From controller-side I've this:

$height = 240;
$width = 120;
// ...
eval("\$width = \"\$width\";");
eval("\$height = \"\$height\";"); 


What can I fix this ? Sad
Reply
#2
Have you tried {$height} and {$width}? And are you using the correct pages when using eval?
Reply
#3
Hi nth!

      Yes and Yes!  

I've been using {$height} and {$width} with no-difference and in showthread.php (controller-side) and editing 'postbit' (view-side)

So ? Sad

You can see the problem here where you see "Ad here" in the right side of the first post and if you inspect the css there it is:


width: px; height: px

But... I'm passing $height 240; and $width 120;

I've updated
Reply
#4
I think nth says usong that values besides the echoes on div.

Use directly this.

{$width}

Besides

<?php echo $width; ?>

Do not use eval that is only called when you load templates inside var values to load all content inside some template.

Only use the code to set width and height values ( i mean php code inside the template ).

That's all and have to work.

Anyway you can use javascript to load values with jQuery codes of course
The only infinite thing is the universe and human stupidity, but the universe is not for sure

Plugins 1.6.x

Plugins 1.8.x

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)