like django
<<<
{% block header %}
placeholder
{% endbock %}
>>>
in qeephp
<<<
<?php $this->_block('header'); ?>
placeholder
<?php $this->_endblock(); ?>
is very useful~!~~~~!~~
Page 1 of 1
Hope to add template function with "block"
#2
Posted 18 November 2009 - 04:53 AM
you mean this?
in layout:
<?php echo $this->clips['left01']; ?>
in view:
<?php $this->beginClip('left01'); ?>
<?php $this->widget('HomeMenu', array('visible'=>true)); ?>
<?php $this->endClip(); ?>
in layout:
<?php echo $this->clips['left01']; ?>
in view:
<?php $this->beginClip('left01'); ?>
<?php $this->widget('HomeMenu', array('visible'=>true)); ?>
<?php $this->endClip(); ?>
#3
Posted 18 November 2009 - 05:06 AM
class PBlock extends CWidget
{
public $blockName = null;
public $isLayout = false;
private static $_blocks = array();
public function init()
{
ob_start();
ob_implicit_flush(false);
}
public function run()
{
$output = ob_get_clean();
if (!isset(self::$_blocks[$this->blockName])) {
self::$_blocks[$this->blockName] = $output;
}
if ($this->isLayout) {
echo self::$_blocks[$this->blockName];
}
}
}in layout:
<?php $this->beginWidget('PBlock', array('blockName' => 'test', 'isLayout' => true));?>
in layout
<?php $this->endWidget();?>in view:
<?php $this->beginWidget('PBlock', array('blockName' => 'test'));?>
in view
<?php $this->endWidget();?>
#4
Posted 19 November 2009 - 12:38 AM
sprint, on 18 November 2009 - 04:53 AM, said:
you mean this?
in layout:
<?php echo $this->clips['left01']; ?>
in view:
<?php $this->beginClip('left01'); ?>
<?php $this->widget('HomeMenu', array('visible'=>true)); ?>
<?php $this->endClip(); ?>
in layout:
<?php echo $this->clips['left01']; ?>
in view:
<?php $this->beginClip('left01'); ?>
<?php $this->widget('HomeMenu', array('visible'=>true)); ?>
<?php $this->endClip(); ?>
Thank you! this way is ok~, but if i use block functioin~like:
<?php $this->block('title'); ?> Home page <?php $this->endBlock(); ?> -- in layouts/main.php
and in my view file:
index.php >>>
unused in this file
show.php >>>
<?php $this->block('title'); ?> Show now <?php $this->endBlock(); ?>
when i render above tow view files, get the title:
index.php >>>
Home Page
show.php >>>
Show now
my mean is , block function have "default", or overwrite, evan append
#5
Posted 19 November 2009 - 12:43 AM
puper, on 18 November 2009 - 05:06 AM, said:
class PBlock extends CWidget
{
public $blockName = null;
public $isLayout = false;
private static $_blocks = array();
public function init()
{
ob_start();
ob_implicit_flush(false);
}
public function run()
{
$output = ob_get_clean();
if (!isset(self::$_blocks[$this->blockName])) {
self::$_blocks[$this->blockName] = $output;
}
if ($this->isLayout) {
echo self::$_blocks[$this->blockName];
}
}
}in layout:
<?php $this->beginWidget('PBlock', array('blockName' => 'test', 'isLayout' => true));?>
in layout
<?php $this->endWidget();?>in view:
<?php $this->beginWidget('PBlock', array('blockName' => 'test'));?>
in view
<?php $this->endWidget();?>This is good way to replace block function~
but, in my opinion, use block in layout file, is the best way~
#6
Posted 19 November 2009 - 12:56 AM
You can use $this->beginClip('test', array('renderClip'=>true))
Share this topic:
Page 1 of 1

Help












