MyBB Hacks

Full Version: Please help with passing vars to template
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi!
      I've a problem with my forum passing php variables to template, I want I'cant pass $width y $height

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

PHP Code:
<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:

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

I've been also trying with {$height} and {$width} with no-difference.

Now you can see the problem here, because "Ad here" in a green box at the right side of the first post should have a width of 120px but.... if you inspect the HTML you see it's EMPTY!

What can I fix this ?


BTW: the problem is NOT the plugin (it's great) but I need all the help I can get Smile

(06-01-2016 06:38 AM)typo Wrote: [ -> ]$height = 240;
$width = 120;
// ...
eval("\$width = \"\$width\";");
eval("\$height = \"\$height\";");
I don't understand the code here (it doesn't really do anything), but a common issue is scoping in PHP.  Try elevating variables into the global scope if it's not showing up (though I don't recommend using the $width/$height names as they may conflict with something else).
Reference URL's