MyBB Community Forums

Full Version: little help with "custom" page
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
What the #$@&%*!? am I doing wrong?!? 


Quote:<html>

<head>
<title> Usergroups</title>
{$headerinclude}
</head>
<body>
{$header}
<table border="0" cellspacing="1" cellpadding="4" class="tborder">
<tr>
<td class="thead"><span class="smalltext"><strong>Usergroups</strong></span></td>
</tr>
<tr>
<td class="trow1">

<div style="width: 48%; min-height:120px; border: 2px #ccc solid; margin: 4px; padding: 2px; border-radius: 5px; float:left;">
<table width="100%" cellspacing="0" cellpadding="5" border="0">
<tr class="trow1">
<td width="75%" border="0">

<span><strong>{$usergroup['title']}</strong></span>
<a href="usercp.php?action=usergroups&amp;joingroup=8&my_post_key={$mybb->post_code}">(Join Group)</a>
<br /><br />
<span class="smalltext">{$usergroup['description']}</span>
</span>

<span class="smalltext">{$usergroupleaders}</span></td>
</td>
<td width="25%" align="right" valign="middle"> 
<img src="http://resources.mybb.com/images/badges/oct_13/support.png" /><br />
</td>
</tr>
</table>
</div>

</td></tr></table>
{$footer}
</body>
</html>

Can't show {$usergroup['title']}, {$usergroup['description']}, {$usergroupleaders} 


Image :$
[Image: 2lxv3bd.png]
(2014-12-11, 08:25 PM)holyshit Wrote: [ -> ]What the #$@&%*!? am I doing wrong?!?

You're basically not understanding what $xxx are - they're PHP variables and each of them has its own scope: http://php.net/manual/en/language.variables.scope.php If you don't define them on your custom page and they're not global, they'll be blank because PHP doesn't know what $randomvarname is out of nowhere.
It doesn't work because the array {$usergroup[]} works only on certain pages.

If you want to work on your custom page you have to write something like this (in the .php file NOT IN THE TEMPLATE):

$usergroups = array();

$query = $db->simple_select("usergroups", "gid, title, usertitle", array('order_by' => 'disporder'));
while($usergroup = $db->fetch_array($query)) {
$usergroups[$usergroup['gid']] = $usergroup;
}
.php file

<?php

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

add_breadcrumb("Usergroups", "usergroups.php");

eval("\$html = \"".$templates->get("usergroups_temp")."\";");

output_page($html);

?>




Any HELP ????
(2014-12-13, 09:37 AM)Clear Wrote: [ -> ]It doesn't work because the array {$usergroup[]} works only on certain pages.

If you want to work on your custom page you have to write something like this (in the .php file NOT IN THE TEMPLATE):


$usergroups = array();

$query = $db->simple_select("usergroups", "gid, title, usertitle", array('order_by' => 'disporder'));
while($usergroup = $db->fetch_array($query)) {
$usergroups[$usergroup['gid']] = $usergroup;
}

$usergroups = $cache->read('usergroups');
I think i'm going to kill myself!
So basically what you need help with; making the page automatic?