Created
March 7, 2011 04:56
-
-
Save balupton/858091 to your computer and use it in GitHub Desktop.
Ajaxify a Website with Server Side Optimisations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Our Page Action | |
public function pageAction ( ) { | |
// Prepare our variables for our view | |
// ... | |
// Handle our view | |
return $this->awesomeRender('page.html'); | |
} | |
// Render Helper | |
public function awesomeRender ( $template ) { | |
// Get the full template path | |
$template_path = ... | |
// Render the template | |
$template_html = $this->view->render($template_path); | |
// Check for the XHR header | |
if ( IS_XHR ) { | |
// We are a AJAX Request, return just the template | |
$this->sendJson({'content':$template_html}); | |
} | |
else { | |
// Wrap the Template HTML with the Layout and proceed as normal | |
// ... | |
} | |
// Done | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@tezqa I think its code is using the PHP
Zend Framework
, which use the MVC pattern (http://en.wikipedia.org/wiki/Model-view-controller). You can learn more about Zend here http://framework.zend.com/manual/en/learning.quickstart.intro.html