MyBB Community Forums

Full Version: Assign values in template variable
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

How can I set the value of {$name}?
This is the template:

<html>

<head>

<title>{$mybb->settings[bbname]}</title>

{$headerinclude}

</head>

<body>

{$header}

<br />

<table width="100%" border="0">

<thead>

<tr>

<th>RULES</th>

</tr>

<tbody>

<tr>

<td>Our rules {$name}</td>

</tr>

</tbody>

</table>

{$footer}

</body>

</html>

This is the code in php file:

<?php

define('IN_MYBB', 1); // (1a)
require "./global.php"; // (1b)

global $name;
add_breadcrumb("Rules page", "rules.php"); // (2)

eval("\$rules = \"".$templates->get("rules")."\";"); // (3)

$name    =    'abc';

output_page($rules); // (4)
?>

Please help me, I am stuck in it.
You have to call the template after assigning the variable Smile
Thanks, it is working now...!

One more thing how can I use loop in template? like in smarty template engine {section} and {foreach} is available.

Do I need to do all things in php and assign result set in it?
Yeah, you have to perform the loop in PHP unfortunately as the MyBB template engine isn't that smart.