Can you add "Placeholder" pluin like Zend Framework in View?

In layout view template:

<?=$this->placeholder("footerjs");?>

In action view template:

<?php $this->placeholder("footerjs")->captureStart();?>

......some complex js script or css tag.

<?php $this->placeholder("footerjs")->captureEnd();?>

can Phalcon add this new feature?



1.7k

Maybe you can check out Phalcon Assets to do that job



1.2k

@ntesic

I had read the Phalcon Assets,But it's can't solve the problem, or can you give me some examples? thank you.



1.2k

thank you,

I known, I means can you add the placeholder feature at next release?

pwtitle, I think I was able to recreate the missing functionality by using output buffering and assigning the results to a view variable as follows:

In the action's view:

<!-- // -------------------------------------------------------------------------------- // --> <?php obstart(); ?> <script type="text/javascript"> $(document).ready(function () { ... }); </script> <?php $this->view->setVar('jscript', obget_clean()); ?> <!-- // -------------------------------------------------------------------------------- // -->

Then, inside the modules "template" view, use that variables as follows:

<!-- Custom Page JavaScript --> <?php if (isset($jscript) && $jscript): ?> <?= $jscript; ?> <?php endif; ?>

This will scoop up the custom JS, exclude it from the action's view, assign it to a view variable, and that variable can be used in the main template to render it in the correct position.

-- Dante