プリロードでブロックを作れないかと思ったら、作れるんですね。知ってる人は知っているのかもですが。
何か特殊なことをしたいときに使えるかも知れません。
<?php
class PreloadBlock extends XCube_ActionFilter
{
protected $index = 'l';
protected $block = array(
'id' => -1,
'name' => 'preload_block',
'title' => 'プリロードブロック',
'content' => '<i>ブロックの内容</i>',
'weight' => -1, // 並び順
);
protected $indexes = array(
'l' => 0,
'r' => 1,
'cl' => 3,
'cr' => 4,
'cc' => 5
);
protected $blocks = array(
'l' => 'xoops_lblocks',
'r' => 'xoops_rblocks',
'cl' => 'xoops_clblocks',
'cr' => 'xoops_crblocks',
'cc' => 'xoops_ccblocks'
);
public function postFilter()
{
if ( $this->mController->_mStrategy->mStatusFlag != LEGACY_CONTROLLER_STATE_PUBLIC )
{
return;
}
$this->mRoot->mDelegateManager->add('Legacy_RenderSystem.BeginRender', array(&$this, 'beginRender'));
$this->mRoot->mContext->mAttributes['legacy_BlockShowFlags'][$this->indexes[$this->index]] = true;
$this->mRoot->mContext->mAttributes['legacy_BlockContents'][$this->indexes[$this->index]][] = $this->block;
}
protected function beginRender(&$tpl)
{
if ( !empty($tpl->_tpl_vars['isFileTheme']) )
{
uasort($tpl->_tpl_vars[$this->blocks[$this->index]], array(&$this, 'reOrder'));
}
}
protected function reOrder($a, $b)
{
if ($a['weight'] == $b['weight'])
{
return 0;
}
return $a['weight'] > $b['weight'] ? 1 : -1;
}
}
?>
詳しいことはこっちに書きました↓
http://suin.asia/2010/01/25/preload_block