我会回避使用这些。您会注意到它们在默认的分布式社区版本中被注释掉,这可能意味着核心团队正在放弃使用它们。
如果您对它们的作用感兴趣,它们是严格属于page/head
块的addItem
方法。
File: code/core/Mage/Page/Block/Html/Head.php
public function addItem($type, $name, $params=null, $if=null, $cond=null)
{
if ($type==='skin_css' && empty($params)) {
$params = 'media="all"';
}
$this->_data['items'][$type.'/'.$name] = array(
'type' => $type,
'name' => $name,
'params' => $params,
'if' => $if,
'cond' => $cond,
);
return $this;
}
add item 方法存储这些条件,然后在稍后的过程中使用它们getCssJsHtml
跳过添加项目的方法。
public function getCssJsHtml()
{
// separate items by types
$lines = array();
foreach ($this->_data['items'] as $item) {
if (!is_null($item['cond']) && !$this->getData($item['cond']) || !isset($item['name'])) {
continue;
}
我的猜测是,他们是向模板系统添加元编程的早期尝试,但最终超出了其目标用户的理解范围。