[geeklog-devel] Suggested changes to block code

Blaine Lang devel at portalparts.com
Sun Jul 22 19:17:23 EDT 2007


Euan,

Looking at the code today, I think it will be easiest to set a 
{block_name} instead of {bid}. I need to extend the COM_startBlock and 
many of the calls to that function may not have the block ID but do have 
the block_name available which is not language specific 'user_menu', 
'admin_menu' but would not be unique if you had multiple poll blocks 
which I think is about the only time you would have multiple blocks of 
the same name. 

I am thinking we extend COM_startBlock to include an 4th optional parm 
and use that to set {block_name} in the block header template. If you 
call it from your own code, that parm can be set to anything but in the 
core GL code, it would be the name field in the block.

I think that should still be unique to us in Javascript - only exception 
being multiple polls on the same page.

Regards,
Blaine

Heather Engineering wrote:
> Blaine,
>
> That sounds fine to me. I already have custom blocks defined in 
> functions.php, so having a {bid} set would be useful.
>
> As a general point, which has come up before, I'm generally in favour 
> of more reusable basic templates and having classes/ids set on 
> everything. Oh, sorry, that was a little off topic.
>
> Cheers,
>
> Euan (who may or may not look like Oliver - I've never seen him).
>
>
>
>
>
> On 2007/07/06, at 12:37, Blaine Lang wrote:
>
>> 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
>>>
>>>
>> _______________________________________________
>> geeklog-devel mailing list
>> geeklog-devel at lists.geeklog.net
>> http://eight.pairlist.net/mailman/listinfo/geeklog-devel
>
> _______________________________________________
> 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