[geeklog-devel] Suggested changes to block code
Heather Engineering
info at heatherengineering.com
Thu Jul 5 21:00:01 EDT 2007
Messing with AJAX-style coding, you soon realise you need ids on
everything.
I've added the following to the block handling code: any interest in
adding it to the next release?
There is no issue with backwards compatibility.
*************************************************************
function COM_formatBlock : add $A['id'] to two COM_startBlock calls
(the function is called with an array $A, so no need to change the
function declaration).
$blkheader = COM_startBlock( $A['title'], $A['help'],
COM_getBlockTemplate( $A['name'], 'header' ), $A
['id']);
$retval .= COM_startBlock( $A['title'], $A['help'],
COM_getBlockTemplate( $A['name'], 'header' ),
$A['id'])
*************************************************************
function COM_startBlock :
add new $id='' to declaration
add $block->set_var( 'id', $id );
I also added hack to check if the caller is passing a link to add a
help file reference, or if they are passing a complete image tag
already wrapped in a link (this is a similar hack to the one already
in COM_formatBlock to check whether to add <br > tags to block
content). An alternative might be to allow the caller to pass a new
image link as well, so that you aren't stuck with the help icon.
function COM_startBlock( $title='', $helpfile='',
$template='blockheader.thtml', $id='' )
{
global $_CONF, $LANG01, $_IMAGE_TYPE;
$block = new Template( $_CONF['path_layout'] );
$block->set_file( 'block', $template );
$block->set_var( 'site_url', $_CONF['site_url'] );
$block->set_var( 'layout_url', $_CONF['layout_url'] );
if ($title==' ') {
$block->set_var( 'block_title', '');
} else {
$block->set_var( 'block_title', stripslashes( $title ));
}
// added
$block->set_var( 'id', $id );
// end add
if( !empty( $helpfile ))
{
// altered
if( substr( $helpfile, 0, 1 ) == '<' )
{
$help = $helpfile;
}
else
{
$helpimg = $_CONF['layout_url'] . '/images/
button_help.' . $_IMAGE_TYPE;
if( !stristr( $helpfile, 'http://' ))
{
$help = '<a class="blocktitle" href="' . $_CONF
['site_url'] . '/help/' . $helpfile
. '" target="_blank"><img src="' . $helpimg
. '" border="0" alt="?"></a>';
}
else
{
$help = '<a class="blocktitle" href="' . $helpfile
. '" target="_blank"><img src="' . $helpimg
. '" border="0" alt="?"></a>';
}
// end alteration
}
$block->set_var( 'block_help', $help );
}
$block->parse( 'startHTML', 'block' );
return $block->finish( $block->get_var( 'startHTML' ));
}
*************************************************************
Cheers,
Euan.
More information about the geeklog-devel
mailing list