PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » HTML » HTML_Template_Sigma » Bug #1653

Callbacks in blocks with remove unknown

Details

Request #1653Callbacks in blocks with remove unknown
Submitted2004-06-16 11:52 UTC
Frombmansion at mamasam dot com
StatusWont fix
PackageHTML_Template_Sigma
PHP Version4.3.7
Roadmaps(Not assigned)

Comments

[2004-06-16 11:52 UTC] bmansion at mamasam dot com

Description:
------------
There are 2 problems. The second one is related to the first one:

HTML_Template_Sigma does not show the result of a callback if it is located in a block.

HTML_Template_Sigma should not display the block if the result of a callback is null.

Reproduce code:
---------------
Here is a small patch that seems to work but I am not sure it is the best way as I didn't spend too much time on it:

Line 628:

if (!is_null($res)) {
$empty = false;
// save the result to variable cache, it can be requested somewhere else
$vars[$placeholder] = $res;
$outer = str_replace($placeholder, $res, $outer);
}

<!-- BEGIN BLOCK_PREPARATION -->Frais de préparation func_getCartValue("preparation") €<!-- END BLOCK_PREPARATION -->

$tpl->setCallbackFunction('getCartValue', array($cart, 'getTotalValue'));

Expected result:
----------------
In case $cart::getTotalValue returns VALUE:

Frais de préparation VALUE €

In case $cart::getTotalValue returns null, nothing.

Actual result:
--------------
Nothing in both cases.

[2004-06-16 14:08 UTC] bmansion at mamasam dot com

The patch doesn't work and create other problems.
I'll investigate that ASAP.

[2004-06-16 15:05 UTC] bmansion at mamasam dot com

It seems that the workaround with 1.11 is to do a touchBlock() before. If the block is not touched, the function it contains will not be used. I guess that this is the intended behavior ?