Skip to content

Instantly share code, notes, and snippets.

@githiro
Created June 6, 2013 23:52
Show Gist options
  • Select an option

  • Save githiro/5726008 to your computer and use it in GitHub Desktop.

Select an option

Save githiro/5726008 to your computer and use it in GitHub Desktop.
PHP: determine template
////////////////////// 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