Ive only heard of templates being stored in a database once. Wayne Luke says vbulletin stores templates in the database for a couple of good reasons. That sort of thing is not for your run of the mill application however.
In another post SweatJe had a go at you because of your posts and I couldn't understand as to why. Now I do
It appears that you are limiting your application in ways that you (yet) do not understand simple because you have this idea that the database templating method is your 'only choice' is what I'm getting from your various posts.
Lastcraft has explained why your choice is bad but what happens for example when you roll out your application and someone requests Postgres or Oracle? Er, exactly... You'd be up the clyde without a paddle (goggle the phase if your lost in the translation).
Very rare occasion you'd use a database for templating (think I said this in another thread?) and for content management I can definitely say that a database storage system is a bad idea for you at this time, for your application and your just giving yourself future problems
As for SweatJe's attitude (in other thread) maybe there is nothing wrong with it after all huh...
Quit spending time making your life more difficult then...Originally Posted by Ian R. Gordon
What is your definition of "good way to program"? If you're not making progress and it is frustrating you, then I'm guessing it is not a "good way to program" so my advice is to try a different approach. Then you can see if it is a "better" or a "worse" way to program. Once you can compare things, you'll at least have something to work with.
I say its frustrating because when I am asking for help people keep telling me I am doing it wrong. I am not asking for an opinion of my method of implementing my script I am just asking how I could get it done.
CSS / XHTML / PHP Programmer
Your first post seems to ba sking for opinions more than anything else, which is what you've gotten. If you were asking specific things, like "how do I get the template from the Database?" (Use SELECT or check out the API of your chosen ORM/DBAL) or "how do I get the variables into the template?" (eval) then you would probably have still have gotten people saying that you shouldn't put your templates in the databaseOriginally Posted by Ian R. Gordon
You can't be stuck on the road with a flat tire and when someone stops to help you out, tell them "well, it is a square wheel that I want to put on my car, so are you gonna help me or not?"; you will more than likely not receive any help, as for anyone with common sense, "help" would be to try and explain to you that a round wheel would work much better. But you don't seem like the type that accepts advice from others, so it's unlikely that you will find any kind of help in these forums with that approach.
I'm getting the feeling that we may well have another Tony here folks, and it's just something we got to put up with
Where's exactly the problem Ian, Wouldn't a select stmnt/eval solution be enough?
If I have wings, why am I walking?
Perhaps you are in the wrong forum. This forum is for:I say its frustrating because when I am asking for help people keep telling me I am doing it wrong. I am not asking for an opinion of my method of implementing my script I am just asking how I could get it done.Here you get a opinion: like it or not. When smart people disagree with me, I start to listen more closely to what they are saying and try to learn (though I'd never let them know that ... oops, just did)1) If you wish to discuss topics such as Object Orientated Programming, Design Patterns and other software development techniques related to PHP then please post in the Advanced PHP Programming forum. If your thread does not deal with the above then the Advanced PHP Programming forum is not what you are looking for.
2) If you need help with a parse error, or would like to know how to achieve something with PHP or have a PHP question that does not fit any other forum then please post in the PHP forum.
Naa, Tony knows he is an a ss. And is proud of it. Ian just likes the relational model much more than the hierarchical filesystem model. He's just putting that preference above the performance/efficiency/ease of coding issues.Originally Posted by Dr Livingston
I'm saying that because I disagree with the Tony label - file system based templates are the best choice. If you give the files .phtml extensions and put them outside the server's public directory, you'll get the 'beauty' of the DB solution plus the performance too. (It is extensions like .tpl.php which make the filesystem solution ugly imo, along with using too many and too split up templates. Avoid both those problems and you beat the hell out of the 'beauty' of the relational setup!)
Perhaps Ian doesn't view things in terms of beauty, but that's my impression for his motivation to move things into the DB. But beauty comes in performance, not just layout. This is design of dynamic systems, the beauty is in the dynamic not some static flow chart.
Ian,Originally Posted by Ian R. Gordon
I think you're wrong to be worried about the database structure at this point. Just build a simple class that fetches a template based on a key:
public function __construct($key)
private function _fetch_template($key)
return "Not implemented yet.";
public function render()
return "<span>" . $this->template . "</span>";
Sorry, man:I don't think this project is particularly hard but, it will take some time and incorporate a vast array of common features seen across multiple blog and CMS scripts.
Oh, I also want to create clean SEF URLs so: http://www.domain.com/index.php?cate...page=iangordon => http://www.domain.com/about/iangordon
So, what I am asking is help with the database structure for MySQL and help with how to implement this templating system.
PLEASE DO NOT TELL ME ABOUT EXISTING TEMPLATE SYSTEMS!!
I already know about them and I am not interested in them, don't make any posts mentioning them PLEASE!!!
There are lots of templating systems out there, and they've solved the various "usual problems": template nesting, variable substitution, etc.
You'll be much better served tearing them apart for ideas and implementations than asking here. WACT, which is popular with many of the SP users, might be a good starting point.
This is not to say you have to model your code on any other system, but that you should get your list of features from there. Do a basic use-case analysis to identify the 10 must-have features, and implement them...
Good luck.This is where I am at right now, working on gettting this working.
You should probably have a look at the wikipedia article on DDT: still not shown to be hazardous.Originally Posted by kyberfabrikken
Perhaps you meant "Alar", which was used to treat apples and has been shown to be harmful?
File system based templates are simply A choice. Ultimately it does not matter where the template data is stored. I see no reason why you couldn't build you own or use one of the many existing templating systems with templates from any data source.file system based templates are the best choice.Filesystem based:So, what I am asking is help with the database structure for MySQL and help with how to implement this templating system.
key - filename
template - file contents
key - primary key field
template - "template" field (type TEXT or BLOB)
Sure, you could even print them out and OCR them whenever someone wants to visit your site:Originally Posted by arborint
key - page number
template - page text
... it is also A choice, though not one I would want to use for the average web app. Performance wise, and complexity of code wise, using the file system is the easiest, and using dead trees is the hardest. That's why you see more people talking about using the file system than using paper to store the data.
It really is that simple. That's why I recommended you just wrap it in a class and get on with the interesting stuff.Originally Posted by arborint
(Note: There are a lot of cool things you can do with DB based templates -- but none of them come into play until you get "basic" template handling to work. So throw something together, put a big "FIXME: this is trash code" in a comment someplace, and move on to the next use case.)
Thanks everyone, I do know I am quite stubborn in my insistence on DB Template Storage system but, its something I already made up my mind about and I don't want to start from square one.
I am right now looking at different implementions in existing template systems of how things are achieved, some aren't useful because they use PHP5 programming but, most are still PHP4 compatiable.
I apologize for seeming rude in my responses, this has been a hell of a week for me in terms of school work and other things. This is also important to me, so I do whig out a bit sometimes.
Thanks again for all your help and I will do some more research regarding this matter.
CSS / XHTML / PHP Programmer
I'll take back what I said earlier about the new Tony, no hard feelings Ian? If it's just a point of being more in favour of one method over another method then there has to be a reasoning behind it, as choosing a database template method has knock on effects as said
still not shown to be hazardous.
That what they (Goverment) said about BSE here in the UK and now look, people are dying of a brain disorder That's what happens when you feed cattle dead chickens and why I've never eaten beaf for the last 8 odd years.
Even worse is feeding cattle cattleOriginally Posted by Dr Livingston
Livingston: BUT, if he then goes on to parade about his DB solution in every second thread as the absolute best despite the obvious dead-chicken problem, then you've got my goahead to call him Tony
(Unless something magic happens when he writes it and it turns out to have the same sort of performance against the expectations of 90% of the people here, in which case I want to know all about how you did it Ian! (though in your own thread please ))
If you layered well; you would only need to switch out your template DAO and change no other code. Just a thought for the design of your application.Originally Posted by Ian R. Gordon
I am wondering about why there was such a violent reaction to a DB Template Storage system. This thread has acutally got me thinking about one of my clients that has an underused backend Postgres server and a heavily used frontend server used for file uploads. I have been thinking that it might make sense to put the template data in the database just to reduce disk activity on the frontend server.
I in general agree that you use file systems for what they are good for and databases for what they are good for. But it is not an absolute rule. Also the advice on layering you application is a good one.
DB based templates might also be useful in a condition where
a) you are allowing client based modification
and b) you have a server farm for load balancing
It would save you the trouble of replicating between file based systemx or the io overhead of a network mounted file resource.
CSS / XHTML / PHP Programmer