Basically, I'm working on an largely AJAX driven website, so using browser-side XSLT to transform XML generated by PHP (after pulling information from a DB) is the way to go.
However, there are cases where users may opt to bypass AJAX, or bypassing AJAX may be required under certain circumstances, and it is up to PHP to generate the ALL the HTML.
For example:
Code: Select all
function renderHomeXML(){
global $session, $database;
$xmlBuffer = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n";
$xmlBuffer .= "<?xml-stylesheet type=\"text/xsl\" href=\"xsl/me.xsl\">\n";
$xmlBuffer .= "<xml>";
$xmlBuffer .= "<user>";
$xmlBuffer .= "<name>" . $session->username . "</name></user>";
$query = "Select COUNT(*) FROM main_messages WHERE msgTo=" . $session->userID . " AND msgRead=0";
$result = mysql_query($query);
$row = mysql_fetch_array($result);
mysql_free_result($result);
$xmlBuffer .= "<messages><new>" . $row['COUNT(*)'] . "</new></messages>";
$xmlBuffer .= "</xml>";
echo $xmlBuffer;
}So I'm left with 2 realistic options:
1. Use the same XML generated by that renderHomeXML function and apply a XSL template using the PHP Sablotron engine and provide the HTML that way. This obviously makes things easier for the web designer who may not be all that proficient in PHP because all they have to do is edit the XSL file directly. However, I am not familiar with the speed and efficieny of PHP XSLT processing, so hopefully someone could enlighten me.
2. Make a new function that just generates HTML immediately and plug DB information in right there and forget XML/XSLT all together when a user accesses the page (home.php) directly.
Again Option 1 makes a web designers job a bit easier, and would allow him to create multiple "user-selectable" templates very easily. Option 2 makes things a bit more difficult for the web designer, but MIGHT be faster.
Hopefully that made some sense and thanks ahead of time to anyone who can shed some light on this