Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Solved: 6 Years, 4 Months, 3 Weeks ago [How To?] Creating Custom Templates
#1
Solved: 6 Years, 4 Months, 3 Weeks ago
Well right now my custom page looks like this:
http://www.coding-forums.com/postactivity.php?uid=1

I read this tutorial on creating custom pages and giving them the design of your theme: http://community.mybb.com/thread-116225.html

But what I don't understand, is how would I do this? Right now, I'm using PHP to write all the html to the document, because there are multiple things I have to loop through. So how would I implement this in the template?

Here's an example of my PHP code:
<!DOCTYPE html>
<html>
<head>
<title>Member Post Activity</title>
</head>
<body>
<table border="0" cellspacing="1" cellpadding="4" class="tborder">
<tr>
<td class="thead" colspan="2"><strong>Member Post Activity</strong></td>
</tr>
<tr>
<td class="tcat"><span class="smalltext"><strong>Forum</strong></span></td>
<td class="tcat" align="center"><span class="smalltext"><strong>Post Count</strong></span></td>
</tr>
<?
foreach ($numPosts as $fid => $count)
{
	$forum = get_forum($fid);
	$fName = $forum['name']; 
	print "<tr>
	<td width=\"85%\" class=\"trow1\"><a href=\"forumdisplay.php?fid=$fid\">$fName</a></td>
	<td class=\"trow1\">$count</td>
	</tr>";
}
?>
</table>
</body>
</html>

Do you see what I mean? I'm looping through an array and printing the results, that's basically my question. How could I loop through this array and print the results in the template? Because it's going to be different for every user.

I'm not sure how I would do this.

Thanks for any help, sorry if I'm not describing this well.
#2
Solved: 6 Years, 4 Months, 3 Weeks ago
Still no results.
#3
Solved: 6 Years, 4 Months, 3 Weeks ago
Still nothing. I have received no support and have not come across any results. Help would be appreciated.

Thank you.
#4
Solved: 6 Years, 4 Months, 3 Weeks ago
(10-14-2012, 03:42 PM)dr3am Wrote: Still nothing. I have received no support and have not come across any results. Help would be appreciated.

I think you might be better off using Page Manager.

There are several examples of how to build a template using PHP and export it with Page Manager here: http://community.mybb.com/thread-63357-page-37.html

You can download Page Manager here: http://mods.mybb.com/view/page-manager

Try using the php.xml example page created by the OP. Wink
#5
Solved: 6 Years, 4 Months, 3 Weeks ago
(10-14-2012, 03:53 PM)Wildcard Wrote:
(10-14-2012, 03:42 PM)dr3am Wrote: Still nothing. I have received no support and have not come across any results. Help would be appreciated.

I think you might be better off using Page Manager.

There are several examples of how to build a template using PHP and export it with Page Manager here: http://community.mybb.com/thread-63357-page-37.html

You can download Page Manager here: http://mods.mybb.com/view/page-manager

Try using the php.xml example page created by the OP. Wink

I want it to be a completely separate page though. Not added on to misc.php.
#6
Solved: 6 Years, 4 Months, 3 Weeks ago
Quite honestly I am new to this as well. And with poor internet connection right now I'm forced to reply with ill researched information.

I believe what you want to use is the following...
eval("\$VARIABLENAME = \"".$templates->get("TEMPLATENAME")."\";");

It is to my understanding that one way to do this is within a PHP file that fetches what you want to display, and then displaying it in the template with a variable.

I wish I could be more precise, I just am quite new to PHP and MyBB coding in general. I hope this points you in the right direction.

#7
Solved: 6 Years, 4 Months, 3 Weeks ago
(10-19-2012, 09:01 PM)Mini` Wrote: Quite honestly I am new to this as well. And with poor internet connection right now I'm forced to reply with ill researched information.

I believe what you want to use is the following...
eval("\$VARIABLENAME = \"".$templates->get("TEMPLATENAME")."\";");

It is to my understanding that one way to do this is within a PHP file that fetches what you want to display, and then displaying it in the template with a variable.

I wish I could be more precise, I just am quite new to PHP and MyBB coding in general. I hope this points you in the right direction.

I know how to do that, what I'm having trouble with is creating the actual template. I don't know how to incorporate using a loop in PHP into that.

Thanks for posting though.
#8
Solved: 6 Years, 4 Months, 3 Weeks ago
What you can do is create a template in your global templates via the ACP.

Go to global templates, (Home » Template Sets » Global Templates) click add template. Give it a name, create the template contents, save.

Then, when you eval, put the name of the template you just added into your template name.

This is not so useful for plugins, but for personal use it works just fine.

Here is an example : http://community.mybb.com/thread-120138-...#pid868062
Random Fish and Sims Maniac
MY PLUGINS
Help MyBBSupport help you - remember to mark your threads as solved


#9
Solved: 6 Years, 4 Months, 3 Weeks ago
(10-19-2012, 08:47 PM)dr3am Wrote: I want it to be a completely separate page though. Not added on to misc.php.

Could you not use a rewrite rule in .htaccess?

Edit: ninja'd. Lee's suggestion is a better one than mine.
Please don't PM me for support. Smile


Forum Jump:


Users browsing this thread: 1 Guest(s)