Help with content management system build.

first… Wow, I haven’t been here in a long time, and the changes look great.


I am currently building a content management system, and wanted to get a couple of pointers, in terms of design.

I am looking at the idea of using functions to build the main part of the site, as a “global functions” page, where the header, including the <insert loop to get css, js, etc files linked to the document> tags.

I guess the question would be, is it better to do it like that, or to just use includes to get the parts of the site rendered?

The reason I ask, is that I don’t really want to get into using the print statement for all of the lines of code. It gets into remembering to use single quotes where I would normally use double, makes my code messy, etc, and things like that. I would prefer to use includes, unless it becomes more combersome for the server.

What do you think?

An example would be:

function makePageHeader($pageTitle, $javascriptIncludes, $cssFiles, $headInclude){
print “n”;
print " n";
print " " . $pageTitle . “n”;

	/* write css includes */
	foreach($cssFiles as $cssFile){
		print "        <link rel='stylesheet' type='text/css' href='" . $cssFile . "'>n";

	/* write Javascript Includes */
	if ($jsArray !="") {
	foreach($javascriptIncludes as $jsFile){
		print "        <script src='" .$jsFile . "' type='text/javascript'></script>n";

	print " </HEAD>n";
	print "	<BODY>n";
	print "<div id='container'>hi theren";


I would then call the functions in the pages…
Thanks for reading, and any tips.


I am glad you like the changes… If I get more time… I will attempt to do more, but it’s limited right now.

Anyway, I am not much into benchmarking PHP pages, but I suspect that if you do an INCLUDE, that it would (generally) be quicker to render than a function call with looping.

I say that because essentially, an include is just a dump of what’s in the included file (not counting any Loops or functions that might be in the included file), where you Looping has logic that requires evaluation.

Personally, I do a combination of both. However, I do the “Looping” logic when I am dealing with information that I pull from the database to give more dynamics to the page. That which remains mainly static, goes into an included file.

Lastly, I try to do my “Main” theme as a regular page, and then “INCLUDE” the “page” content in another document.

So for example at PHPHELP.COM The main structure (with different sections) is one page with an Include for links, sponsors, related content, “Latest Topics” , etc… I call this my “Shell” from there I can just “Include” the Various Main Sections for the page. So when I need to Update the Links section, I only change one included file, then all pages are up to date.

Ok, so I ramble… Sorry. I hope it helps though.

That’s what I was thinking. I will build the skeleton and use includes to build it.

Mine is going to have the “web” front end, with a cms back end for building content.

the user logs in, and creates, modifies, etc, documents, which will be saved in the db, and pulled upon url load. quite simple really, but I have a guy that is doing something similar, and is using functions to build the site. I didn’t understand why he is doing it like that.



Basically both ways are possible, and unless you expect heavy traffic, the differences in resources and processing time for the server would be insignificant. I see you mentioning a CMS though. I’ve been working on one as well, and I store my HTML as templates in the database (using a semi-intelligent caching system to keep the number of SQL calls down). This is only required when over 70% of your page layout will be dynamic though.

If you only use the CMS for the backend, you could have PHP render HTML pages (as in actual files) and have those files be copied to your (public) web directory. That would make heavy traffic not bother the PHP/database at all, as they would just see the HTML pages. This has a pro and a con though: the pro is that if there’s an issue with your PHP engine/database, the HTML pages will still be available (as long as your webserver runs). The con is that the HTML pages may be outdated, or (shortly) unavailable while they’re being updated.

My friend’s is being built with high traffic volume in mind, as a social network of websites/communities. He is building it as a pure programmer, and his build makes sense for that.

My problem is that I am a web programmer, not a desktop programmer, and I just haven’t done anything this big, as yet. The logic is similar, but he is more defined. I’m trying to wrap my head around the concepts he’s using, and wondering wether it’s the right idea for the site I’m building for this client. Logically it makes sense, but do I “have” to use it, you know what I mean?

The CMS traffic will be minimal, as the documents will be created before launch, and then there will be periodic updates, and additions to the site by the client. It is going to give him the ability to maintain the site himself, via a control panel, content wise. He can simply add a new “page”, and make it active, or IP.

The site traffic itself will be minimal, unlike a social network. I guess that answers the question.

The idea for mine is that there is a series of “global functions” that I am going to use. Ones that will build the page “header”, building the document up to the tag, using for loops to go through the css, js irectories and linking the external css and js files, check the user auth, build the footer, which will include the end of the file ( etc.), create the main menu (kind of a main category idea), then build the document tree menu based on the main menu link selected.

That way, the site’s owner can create/edit documents and ads, without destroying the code, and I don’t have to worry about charging/not charging to do small things. You know, the “where do I draw the line?” and not charge, but then get taken advantage of? This way, he only needs to call me when he needs something major.

Thanks for the insight, and for letting me talk it out. Now, off to build the db. :)

If this is a project you’re doing for someone else (which you make it sound like), then drawing the line between charging and not charging is easy: there is a functional design (or there should be) in your contract, which should list what is included and what not. If the after-care consists of anything that’s not described there: charge.

Sponsor our Newsletter | Privacy Policy | Terms of Service