![]() |
|
|
||
|
This tutorial takes you through a PHP & MySQL powered template engine. The engine allows you to seperate code and design entirely.
First you need to download the attached project files, and run the "symplyte.sql" commands to set up your database. PHP Code:
Click here for the Symplyte website |
|
|
||
|
Mished,
For the record, I posted your article in several high traffic websites: Hopefully a few will step in and kick this off, get it kicking. http://www.sitepoint.com/forums/showthread.php?t=541320 http://www.programmingtalk.com/showthread.php?p=144317 http://forums.devnetwork.net/viewtopic.php?f=2&t=81055 http://www.dynamicdrive.com/forums/s...d.php?p=138369 http://www.openwebdesign.org/forum/s...=4474#post4474 Please update that link or use a refresh tag to the new page (don't kill that url). Cal Last edited by calfellows : 04-11-2008 at 01:38 PM. |
|
|
||
|
Quote:
how you design your page is entirely up to you - the html supplied is only an example, and is not intended to be used (unless you really want to). yes, I agree that the CSS could be placed in a new template - this would allow site-wide changes of the style. I quite commonly split all my pagews up into the following templates: $header $footer $style $headinclude $navigation and then have my main $content. i removed the $_GET as it was not really required to demonstrate the engine - the engine was designed barebones, so any code you wish to add then please do so. |
|
|
||
|
This tutorial is a *BAD* idea and demonstrates shockingly bad design, ideas, and code practices. Not that bad PHP is a surprise, but the point stands. You show little skill with the language and obviously do not understand how the LAMP stack works.
You should *never* be using raw MySQL queries unless you know what you are doing; you obviously do not. You should always be using a wrapper to allow for formatted queries in the form of prepared statements, specifically with PDO ( http://php.net/pdo ) or MDB2 ( http://pear.php.net/MDB2 ). If you *are* going to use raw MySQL queries, you need to be at least somewhat cognizant of failure. This code is ripe for SQL injection when used by a less-than-competent programmer; a function to neuter any data passed as a query string is essential. (You do not need such a function when using PDO or MDB2; when you pass the prepared statement a variable it automatically handles variable neutering.) Given a naive user of this code, I would expect them to simply pass the value of a $_GET entry into engine::fetchtemplate(), at which point I simply pass the literal shown below in as that GET value: unimportant'; EMPTY templates; SELECT * FROM templates WHERE templatename = ' The above string would cause your query to empty your database. Something tells me that's not quite a good idea. Furthermore, the entire idea behind your incredibly basic "system" is foolish. Unless you know why you are storing your *static pages* as database entries, you're doing it wrong. It isn't "easier to manage and edit"; that's preposterous when you have the option of tools with built-in SFTP controls. This is wankery for the sake of wankery. It is slower than using static files unless you have an enormous number of templates (and even then the benefit is on the order of microseconds), it is exponentially less reliable, and your perceived "ease of management" is a crock. (Oh, and a tip: this doesn't "separate code and design" at all.) Learn to program and learn to think before writing "tutorials" that will be more likely to harm learning programmers than help them. I'm sorry to be a bit of a twat, but teaching people wrongly is far worse than not teaching them at all. |
|
|
||
|
Edr and all,
A better approach would have been simply to offer specific suggestions or chunks for the project. I've participated in several such projects as a html page designer only; and my interest is mainly to see/learn and know exactly what's under the hood Look at the size of the file, 2042 bytes. Wordpress/Smarty/Joomla is what, 10MB , and with their own programming language Traffic to this article has been significant; would actually pay the hosting and domain fees, and then some. Keep up the good work Chris. Add a version #, update link, copyright notice, mandatory credit notice/warning, and instructions/suggestions to the top of the script. You might also consider storing your download link at http://sourceforge.net/ , popular thing to do, and helps with exposure, traffic, and design/support/suggestions. EDr, please stick around, offer specifics to secure the current 2kb, and to implement a respectable front controller script....... http://tinyurl.com/59lq3w Regards, Cal Last edited by calfellows : 04-12-2008 at 10:12 AM. |
![]() |
| Thread Tools | |
| Display Modes | |
|
|