Hi:

i did this sometime ago, i was using ZF 1.1.

first extents Zend_View_Abstract class.

class MyPHPTal extends Zend_View_Abstract
{
    protected $_engine = null;
    protected $templatePath = "/tmp/";
    public function __construct($config = array())
    {
        $this->_engine = new PHPTAL();
        $this->_engine->setEncoding("UTF-8");
        $this->_engine->setPhpCodeDestination($this->templatePath);
        $this->_engine->getPhpCodeDestination();
        parent::__construct($config);
    }

    private function loadEnvironment($config = array())
    {
        if (isset($config['templatepath']) &&
trim($config['templatepate']) != "") {
            $this->templatePath =       $config['templatepate'];
        }
    }

    public function getEngine()
    {
        return $this->_engine;
    }

    public function assign($spec, $value = null)
        {
            $this->_engine->set($spec,$value);
            //$this->_engine->$spec = $value;
    }

    protected function _run()
    {
        $this->_engine->setTemplate(func_get_arg(0));
        echo $this->_engine->execute();
    }
}

second : create a customized ViewRender

class My_ViewRender extends Zend_Controller_Action_Helper_ViewRenderer
{
        //master page.
        protected $_layoutFileName = '/../layouts/layout.phtml';

        public function setLayoutFileName($name)
        {
            //zend view will search this script within
application/views/scripts directory
                $this->_layoutFileName = $name;
        }

        public function renderScript($script,$name=null)
        {
                   /*
                    $script is a path.
                    for example:
                        when we access index/index,  that means
calling index method inside index controller.
                        the $script will be index/index.phtml
               *     */
                   if($name===null)
                        $name = $this->getResponseSegment();
                $this->view->assign('LAYOUT_CONTENT',$script);
                $this->getResponse()->appendBody(
                        $this->view->render($this->_layoutFileName),
                        $name
                );
                $this->setNoRender();
        }

        public function getName()
        {
            return "ViewRender";
        }
        
}

third:

someway in your program, you need to setup PHPTal view.

$view = new MyPHPTal($config);
$viewRender = new My_ViewRender();
$viewRender->setView($view);
Zend_Controller_Action_HelperBroker::addHelper($viewRender);

now in your controller, you can use PHPTal.

$this->view->assign("name","myname");

if you want to change master page,you can do like this:

$this->_helper->getHelper('ViewRender')->setLayoutFileName("/../layouts/popup.phtml");
// you normal master page changed to popup style master page.

regards,

anru

On Wed, Dec 10, 2008 at 1:47 AM, Urša Baričević <uba...@gmail.com> wrote:
> Hello,
>
> Is there any guide step by step guide to integrate PHPTAL with Zend
> Framework?
> I have found:
> http://blog.realmofzod.com/2008/04/14/how-to-make-them-work-together/
> which looks very promising,
> but unfortunately the most important links do not work…
>
> I have done it extending Zend_View,
> but this way I do not have access to Zend Helpers.
>
> What about using PHPTAL cache instead Zend_Cache
> and PHTPAL i18n instead Zend translation engine?
>
> best wishes,
> Urša Baričević
>
> _______________________________________________
> PHPTAL mailing list
> PHPTAL@lists.motion-twin.com
> http://lists.motion-twin.com/mailman/listinfo/phptal
>
>
_______________________________________________
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal

Reply via email to