[geeklog-devel] Suggested changes to block code
Blaine Lang
devel at portalparts.com
Thu Jul 5 23:37:01 EDT 2007
Oliver,
With respect to the ID for ajax usage or any DOM udpates via JS, what if
we just set a template var called {bid} and you could then combine {bid}
and a custom block template defined in the themes functions.php if you
wanted to have a div id with a name like 'myblock{bid}' or we could just
add a default id to the block-header.thtml files using {bid}.
That would then not require much of any changes and no changes to the
function definitions.
Blaine
Heather Engineering wrote:
> 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.
>
> _______________________________________________
> geeklog-devel mailing list
> geeklog-devel at lists.geeklog.net
> http://eight.pairlist.net/mailman/listinfo/geeklog-devel
>
>
More information about the geeklog-devel
mailing list