Starting A Website/Server-Side Services
Frameworks
[edit | edit source]When designing an application there may be a discussion of using a so called framework or not. A framework is simply a bunch of functions and/or classes that makes common tasks simpler to do. Though a framework may not always be necessary because if a developer is good at reusing code it might have developed a own small framework of reusable code.
Example of one page:
<?php
require_once "libs/App.class.php";
$a = new App("index");
$a->add("menu", "menu.tpl");
$a->add("content", "index.tpl");
$a->render("frame.tpl");
?>
Smarty
[edit | edit source]The only framework that is really useful for this project is the Smarty template engine. There are a bunch of other frameworks around, but from experience a framework can sure bring all kind of glory and bells and whistles. Though when it comes to performance and such everything depends on the framework, and if something goes wrong you probably do not want to go inside a framework and mess around with the code. The thing is, If you have code it yourself you can also fix it.
jQuery
[edit | edit source]Smarty is a way of splitting HTML-layout from PHP-logic. Though when an application grows, the need for JavaScript might increase and clutter the html-code. A framework named jQuery might solve this since it separates JavaScript from the html itself. It also simplifies common tasks such as the commonly used ajax-technology.
How to do ajax with jQuery
[edit | edit source]A common use of ajax is to load a chunk of html to somewhere on a web page. This may be a problem since XHTML is not that descriptive of the information. Then it is better to load XML information from ajax and transform it to XHTML. Then you have the XML left on the client side to reuse. Therefore minimizing the database calls needed.