HomePHP Page 5 - Building a Site Engine with PHP, Part 5
Build your very own Theme Park! - PHP
So you want to use your site engine that you’ve been working on? Okay, now is the time for me to show you how to add plug-ins, modules, blocks, and templates to your database so that they will work with your engine. It’s not that hard to do, and with just a few simple steps, you’ll be running your site off your new stylish site engine in no time.
Templates are very easy to set up and install. Basically you only have one table to mess with when installing a template, however you actually have to put information into two tables. You just said “huh!?” Well to begin you have the table that holds all the information about the templates, but then you also have the template_users table which contains all the information about what users are using which template. So you kind of have to set up both.
The templates table is where you’re going to put in information about the template name, the template author, the template’s install date, the template file and the template status. Just like all other components, the template author and the template date are optional. The first field is t_name; this contains the name of the template file. I did it this way so you could have more than one template in the same folder in case you have templates that are slight variations of other templates. Then there is the t_file field, which is more like the plugin_file. Put in the name of the folder that contains the actual template. After that you have the t_status which is where you’d set the default template but put in the word “loaded”. Otherwise you can leave it blank or put in a value other than “loaded”. And by now you should already know what to do with the t_name and the t_date fields. I leave them blank, but I like to know they are there in case I want to use them.
In the template_users table all you have is a field named user_ID that holds the user_ID that corresponds to the user_ID in the users table. After that is the t_ID, which is the ID that is given to a template when you install it into the database, by the auto increment field in the templates table. I have it automatically fill in this information when a user registers so that way you don’t have to do anything with the table at all. That’s all up to you, but personally I wouldn’t like making a full time job out of manually updating the database.
It’s all Over
This is the last part of the last article in this series. If you’ve read all 5 articles, you should now have a good understanding on how to build a site engine. These articles weren’t made to give you a site engine; rather I wrote them to touch on the more confusing parts of building something like what I have. I hope that my articles have helped you to learn some cool new things about how you can work with PHP to make a seemingly self-aware site. And I hope that it’s furthered you in your knowledge of PHP. I’d be happy to lend more information and pointers in the future to those that need a bit of help. I’d also love to see what you can produce while keeping this series of articles in mind. But for now I’ve about said all I think I can say about the theories, ideas, and structure behind a true site engine. Thanks for reading my articles.