深入研究代码,看起来模板逻辑是由函数中的Varien_Filter_Template
(在 lib\Varien 而不是 app\code 下)实现的,如果模式与正则表达式匹配,filter
该函数会向函数发出回调。反过来使用该ifDirective
功能来评估您的状况。然后将条件标记为属性或方法。 ifDirective
_getVariable
if
_getVariable
Varien_Filter_Template_Tokenizer_Variable
if($this->isWhiteSpace()) {
// Ignore white spaces
continue;
} else if($this->char()!='.' && $this->char()!='(') {
// Property or method name
$parameterName .= $this->char();
} else if($this->char()=='(') {
// Method declaration
$methodArgs = $this->getMethodArgs();
$actions[] = array('type'=>'method',
'name'=>$parameterName,
'args'=>$methodArgs);
$parameterName = '';
} else if($parameterName!='') {
// Property or variable declaration
if($variableSet) {
$actions[] = array('type'=>'property',
'name'=>$parameterName);
} else {
$variableSet = true;
$actions[] = array('type'=>'variable',
'name'=>$parameterName);
}
$parameterName = '';
}
当检测到 if 条件是一个方法时,它将执行该方法,否则它只是返回变量的字符串值。
所有这些都意味着(我认为!)如果你想在 if 语句中计算一个表达式,你需要添加一个模板可以计算的新客户属性(有可用的扩展)。因此,如果您定义一个布尔“isMemberOfGroupNameX”属性,那么模板应该可以工作。
我想这不是您要寻找的答案,但我很确定情况确实如此。
HTH, 法学博士