Please help with passing vars to template
typo Offline
Junior Member
**
Posts: 1
Joined: Jun 2016
Post: #1
Sad Please help with passing vars to template
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

(This post was last modified: 06-02-2016 04:45 AM by typo.)
06-01-2016 06:38 AM
Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,338
Joined: Jan 2008
Post: #2
RE: Please help with passing vars to template
(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).

My Blog
06-22-2016 05:57 PM
Find all posts by this user Quote this message in a reply

« Next Oldest | Next Newest »

 Standard Tools
Forum Jump: