Created
June 6, 2013 23:52
-
-
Save githiro/5726008 to your computer and use it in GitHub Desktop.
PHP: determine template
This file contains hidden or 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
| ////////////////////// public_html/controllers/IndexController ////////////////////// | |
| <?php | |
| class IndexController extends Zend_Controller_Action | |
| { | |
| public function loadTemplate($name) | |
| { | |
| if (!array_key_exists("isAjax", $_POST)) | |
| { | |
| $this->view->action = $name; | |
| $this->_forward('container'); | |
| } | |
| } | |
| public function indexAction() | |
| { | |
| $this->loadTemplate("index"); | |
| } | |
| public function containerAction() | |
| { | |
| //containerAction automatically loads "smarty/templates/index/container.tpl" | |
| } | |
| } | |
| ////////////////////// public_html/smarty/templates/index/container.tpl ////////////////////// | |
| <!-- ...html elements --> | |
| <div id="container"> | |
| {if isset($action)} | |
| {include file="index/$action.tpl"} | |
| {/if} | |
| </div> | |
| <!-- html elements... --> | |
| ////////////////////// public_html/smarty/templates/index/index.tpl ////////////////////// | |
| {include file="index/$action.$lang.tpl"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment