MyBB Community Forums

Full Version: How to make tables using theme template
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I know its really simple to make a table but Im trying something different, so I got this so far of code in my Page Im making but I want the table chart thats inside the table (its actually a content block on my website) to look like the tables used in the forum display.

<!-- Stylesheet: Start -->
<style>
#table td, #titles th	{
	font-size:1em;
	padding:3px 7px 2px 7px;
}

#table th	{
	font-size:1.1em;
	text-align:left;
	padding-top:5px;
	padding-bottom:4px;
}
</style>
<!-- Stylesheet: End-->

<!-- Content: Start -->
<table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder">
	<tr>
    	<td class="thead"><strong>Title of my crap</strong></td>
	</tr>
  <tr>
   	<td class="trow1">
			<p>my crap</p>
                                    
			<table id="table" width="100%" border="1" cellpadding="3">
				<tr>
                	<th scope="col">h1</th>
                   	<th scope="col">h2</th>
                    <th scope="col">h3</th>
                    <th scope="col">h4<strong></strong></th>
                </tr>
                <tr>
                    <td align="left" scope="row">blank</td>
                    <td>blank</td>
                    <td>blank</td>
                    <td>blank</td>
                </tr>
                <tr>
                    <td align="left" scope="row">blank</td>
                    <td>blank</td>
                    <td>blank</td>
                    <td>blank</td>
                </tr>
                <tr>
                    <td align="left" scope="row">blank</td>
                    <td>blank</td>
                    <td>blank</td>
                    <td>blank</td>
                </tr>
                <tr>
                    <td align="left" scope="row">blank</td>
                    <td>blank</td>
                    <td>blank</td>
                    <td>blank</td>
                </tr>
                <tr>
                    <td align="left" scope="row">blank</td>
                    <td>blank</td>
                    <td>blank</td>
                    <td>blank</td>
                </tr>
                <tr>
                    <td align="left" scope="row">blank</td>
                    <td>blank</td>
                    <td>blank</td>
                    <td>blank</td>
                </tr>
            </table>
	  </td>
	</tr>
</table><br>
<!-- Content: End -->

Anyways so ya, I want it to look like the forum page using the theme templates (I've got some parts of that already as you can see).

Anyways thanks in advanced...
(2012-03-13, 04:06 PM)BizBink Wrote: [ -> ]I know its really simple to make a table but Im trying something different, so I got this so far of code in my Page Im making but I want the table chart thats inside the table (its actually a content block on my website) to look like the tables used in the forum display.

<!-- Stylesheet: Start -->
<style>
#table td, #titles th	{
	font-size:1em;
	padding:3px 7px 2px 7px;
}

#table th	{
	font-size:1.1em;
	text-align:left;
	padding-top:5px;
	padding-bottom:4px;
}
</style>
<!-- Stylesheet: End-->

<!-- Content: Start -->
<table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder">
	<tr>
    	<td class="thead"><strong>Title of my crap</strong></td>
	</tr>
  <tr>
   	<td class="trow1">
			<p>my crap</p>
                                    
			<table id="table" width="100%" border="1" cellpadding="3">
				<tr>
                	<th scope="col">h1</th>
                   	<th scope="col">h2</th>
                    <th scope="col">h3</th>
                    <th scope="col">h4<strong></strong></th>
                </tr>
                <tr>
                    <td align="left" scope="row">blank</td>
                    <td>blank</td>
                    <td>blank</td>
                    <td>blank</td>
                </tr>
                <tr>
                    <td align="left" scope="row">blank</td>
                    <td>blank</td>
                    <td>blank</td>
                    <td>blank</td>
                </tr>
                <tr>
                    <td align="left" scope="row">blank</td>
                    <td>blank</td>
                    <td>blank</td>
                    <td>blank</td>
                </tr>
                <tr>
                    <td align="left" scope="row">blank</td>
                    <td>blank</td>
                    <td>blank</td>
                    <td>blank</td>
                </tr>
                <tr>
                    <td align="left" scope="row">blank</td>
                    <td>blank</td>
                    <td>blank</td>
                    <td>blank</td>
                </tr>
                <tr>
                    <td align="left" scope="row">blank</td>
                    <td>blank</td>
                    <td>blank</td>
                    <td>blank</td>
                </tr>
            </table>
	  </td>
	</tr>
</table><br>
<!-- Content: End -->

Anyways so ya, I want it to look like the forum page using the theme templates (I've got some parts of that already as you can see).

Anyways thanks in advanced...
not quite sure what you mean .... do you want to add this code to a template and add mybb arrays/variables ?

No, I want to make table just like the forums display (well at leaset look like it)
(2012-03-13, 08:54 PM)BizBink Wrote: [ -> ]No, I want to make table just like the forums display (well at leaset look like it)

well install the pagemanager plugin http://mods.mybb.com/view/page-manager and add some code like

<?php
global $headerinclude, $header, $theme, $footer, $templates, $lang, $mybb;

if ($mybb->user['usergroup'] == "6") 
{
$a='<br>User Privs are below expected to query the data';
$av="<br>Hello ".$mybb->user['username'];}

elseif ($mybb->user['usergroup'] == "4") 
{$a="<br>".$mybb->settings['bbname'];
$av="<br>Hello ".$mybb->user['username'];
$b="<br>Email :- ".$mybb->settings['adminemail']."</br>";
}
//echo $av;
$template = '<html>
<head>
<title>Search My Services</title>
{$headerinclude}
</head>
<body>
{$header}
{$errors}
<table border="0" cellspacing="0" cellpadding="0" class="tborder2">
<tr>
<td class="trow3" valign="top" style="color: #000000; border-style:solid; border-color: #FF0000; border-width: 1px;" align="center">
$av<br>
<strong>This Page is currently under construction</strong><br>
thank you $a $b<br>

</td>
</tr>
<form action="' . $_SERVER['REQUEST_URI'] . '" method="post">
<input type="hidden" name="my_post_key" value="{$mybb->post_code}" />
<table border="0" cellspacing="' . $theme['borderwidth'] . '" cellpadding="' . $theme['tablespace'] . '" class="tborder". width="50%">
<thead>
<tr>
<td colspan="2" class="thead">
<strong>Search My Services</strong>
</td>
</tr>
</thead>
<tbody>
{$usertemplate}
<tr>
<td width="10" class="trow1"><strong>House Name or Number</strong></td>
<td width="20" class="trow1"><input type="text" class="textbox" size="20" name="subject" value="{$subject}" /></td>
</tr>
<tr>
<td valign="top" width="10" class="trow2"><strong>Street</strong></td>
<td width="20" class="trow2"><input type="text" class="textbox" size="30" name="subject" value="" /></td>
</tr>
<tr>
<td width="15" class="trow1"><strong>Post Code</strong></td>
<td width="20" class="trow1"><input type="text" class="textbox" size="10" name="pcode" value="{$pcode}" /></td>
</tr>
{$captcha}
</tbody>
</table>
<br />
<input type="hidden" name="action" value="do_email" />
<div align="center"><input type="submit" class="button" value=" Lets See What We Can Find " /></div>
</form>
</table>

{$footer}
</body>
</html>';

$template = str_replace("\'", "'", addslashes($template));

add_breadcrumb($pages['name']);

eval("\$page = \"" . $template . "\";");

output_page($page);

?>
this will give you a start
the code you gave is all bugged and the variable's are wrong and all :/ sorry but I cant even use it or edit it since Im a beginner with PHP
(2012-03-16, 05:59 PM)BizBink Wrote: [ -> ]the code you gave is all bugged and the variable's are wrong and all :/ sorry but I cant even use it or edit it since Im a beginner with PHP

I guess you do not have the php conditionals plugin installed, you will need that installed for it to work look here
pre requests:
page manger - Use MyBB Template = no
php conditionals plugin installed

as to the variables defined I can not see an error
$mybb->user['usergroup'] returns the current user 'usergroup' this will allow you to then do something regarding the current users 'usergroup'

this defines a <cr> and the board name to $a
$a="<br>".$mybb->settings['bbname'];

but to view the above code working go here
if you view the above link as a guest no user name will be displayed in the first table, but if you log in the user name will be displayed.

Sorry for assuming that you could read the code, but as you can see there are custom classes for the table elements e.g "tborder2" which would have to be changed to "tborder" if your css file is standard. Perhaps it's time to do some more research on how to use php.
Quote:as to the variables defined I can not see an error
$mybb->user['usergroup'] returns the current user 'usergroup' this will allow you to then do something regarding the current users 'usergroup'

My bad.. not the variables. Line 70 is one of the errors and theres more after, its like a mouse and cat game LOL

Quote:I guess you do not have the php conditionals plugin installed, you will need that installed for it to work look here
pre requests:
page manger - Use MyBB Template = no
php conditionals plugin installed

Is this what your talking about for the plugin? Here

Quote:Perhaps it's time to do some more research on how to use php.

And yes it is, again Im a beginner and still learning. I have a friend whos teaching me most of the crap I know now haha but it isnt enough yet. Right now is a good example
(2012-03-16, 07:54 PM)BizBink Wrote: [ -> ]My bad.. not the variables. Line 70 is one of the errors and theres more after, its like a mouse and cat game LOL

Quote:I guess you do not have the php conditionals plugin installed, you will need that installed for it to work look here
pre requests:
page manger - Use MyBB Template = no
php conditionals plugin installed

Is this what your talking about for the plugin? Here



And yes it is, again Im a beginner and still learning. I have a friend whos teaching me most of the crap I know now haha but it isnt enough yet. Right now is a good example

the plugin is at here

line 70 = </body> which just closes the html body tag
the rest of the file is this
</html>';

$template = str_replace("\'", "'", addslashes($template));

add_breadcrumb($pages['name']);

eval("\$page = \"" . $template . "\";");

output_page($page);
</html> closes the html tag and returns control back to php,
after that its just standard functions to add the page name to the breadcrumb menu and then output the page .... make sure you have the template option turned off in page manager or it will never work as php is disabled, so errors will occur when php code is parsed