Question

I have fairly complex HTML document to generate that is of the form

<head> (a css that needs to be inserted here) </head>

And a body with several flavors of templated bits of HTML. Simplistically, I'd probably have one PHP function (let's pretend the domain is news articles since that's simplest) like

generateNewsBlob($title, $author, $imageSrc)
showUserInfo($userInfoStruct)
//etc.

that will output HTML with the arguments filling in the templates.

At minimum I just want a nice folder with easy to edit PHP and easy to edit HTML and CSS. As of now I have it all smooshed together in a .php file - something like 'lots of HTML <img src="' . $imgSrc . "'> more HTML ...' which makes it very hard for our designer to make modifications and our coder (that'd be me) to make modifications. So I need this to be decoupled. But I'm not sure how to have a pure html file that has "holes" to be filled in by the php, because I would implement those holes in PHP... catch-22.

It's been suggested in a previous SO question that MVC is the way to accomplish this. This sounds believable but I have no actual idea how to go about this. I can't bring in any IDE - a developer should be able to work on this in a text editor from console.

Python and Java are also options if those would happen to be "better."

Was it helpful?

Solution

There are lots of MVC frameworks for PHP and other platforms. http://www.phpwact.org/php/mvc_frameworks There are lots of benefits to using those but if you want something simpler, you can just use a PHP templating engine http://www.smarty.net/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top