• Advertisement
Sign in to follow this  

[web] PHP - designing forum template system...

This topic is 4278 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm making a forum once again, however all my forums have had a specific purpose and they were for my use only so I never really made a template system for people to add on their own feel since they were not made for that. But now I want to make a free forum system for my friends and others so now I have to face the ugly processes of templating. So I think I know enough PHP to get started, I created a rough draft template that's called index.tpl. There's a special kind of code in it like this:
	 <drs::beginForum>
	  <drs::topic>
	  <tr>
	   <td valign="top" align="left" width="100%">
	    {FTOPIC}
	   </td>
	  </tr>
	  </drs::topic>
	  <tr>
	   <td valign="top" align="left" width="100%">
	   <table align="left" width="100%" border="0">
	  <drs::ItemTemplate>
	    <tr>
		 <td valign="top" align="left" width="33%">
		  {FTITLE}
		 </td>
		 <td valign="top" align="left" width="33%">
		  {FTOPICNUM}
		 </td>
		 <td valign="top" align="left" width="33%">
		  {FTOPICMOD}
		 </td>
		</tr>
	  </drs::itemtemplate>
	 </table>
	   </td>
	  </tr>
	  </drs::beginforum>
But I'm wondering while programming my template.php engine, I'm trying to write a parser, and yes I know there are already systems out there that do this for you but I want to do it on my own. I was hoping to get some input on like how to go from here. Like do I preform a ereg function to see if certain tags are present, then execute certain functions? Or is there a better way to do it? Thanks. Side note: and yes I'm also adding css swaping for text and body appearance changes without editing the template directly.

Share this post


Link to post
Share on other sites
Advertisement
Is there a reason you're writing your own? Smarty works quite well.

Quote:
index.php
include('Smarty.class.php');

// create object
$smarty = new Smarty;

// assign some content. This would typically come from
// a database or other source, but we'll use static
// values for the purpose of this example.
$smarty->assign('name', 'george smith');
$smarty->assign('address', '45th & Harris');

// display it
$smarty->display('index.tpl');


And the template

Quote:
index.tpl
<html>
<head>
<title>User Info</title>
</head>
<body>

User Information:
Name: {$name}
Address: {$address}

</body>
</html>

Share this post


Link to post
Share on other sites
And if you /really/ don't want to use an existing templating system then there's still the option of having the PHP output XML instead of XHTML and running an XSLT over it to do the actual conversion. People can then edit the XSLT and the CSS to get the forum to look like whatever they want.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement