[drupal-devel] [feature] Let other module use the block matcher

chx drupal-devel at drupal.org
Mon Apr 4 05:37:10 UTC 2005


Issue status update for http://drupal.org/node/19694

 Project:      Drupal
 Version:      cvs
 Component:    block.module
 Category:     feature requests
 Priority:     normal
 Assigned to:  chx
 Reported by:  chx
 Updated by:   chx
 Status:       patch
 Attachment:   http://drupal.org/files/issues/block_regions_0.patch (3.56 KB)

The original phpdoc said "block objects". Object -- good word, we know
what is an object, it is an encapsulation, it has properties, it has
methods. The properties of a block object define where should we care
about this object. Its constructor is a normal PHP function -- never
forget, a plain HTML page can be considered valid PHP code. So,
block_list matches the properties against given conditions and if we
have a match, it calls the constructor, stores the output (if any) and
returns the collection of said outputs.
What has happened to 'region'? There is no region in the above text.
Oh, 'region' is just a confusing word and vauxia said I'd be better
using 'collection'.


chx



Previous comments:
------------------------------------------------------------------------

March 30, 2005 - 13:43 : chx

Attachment: http://drupal.org/files/issues/blocks_regions.patch (1.74 KB)

This patch makes sure that block.module deals by default only with
regions 0 and 1 as it does now but lets you use block_list with any
region you define. This opens many possibilites. You may do a multi
region module, with your admin UI using the blocks table as storage and
the block_list matcher. Or you may do a sections module using the block
matcher without cluttering the current blocks list.
block_list has a phpdoc: * @param $region main|left|right but I have
not found anything regarding 'main' so I changed this to left|right|all
where all means (left or right). As the current block module would treat
'main' the same as 'right' I doubt it had any usage.
In short: no functionality is harmed, lots of possibilities are opened,
so please commit.


------------------------------------------------------------------------

March 30, 2005 - 14:33 : Bèr Kessels

A big +1 from me. 
This helps me make sections module a lot smaller and nicer. Sections
module is very popular, but I cannot keep it complelety synchronised
with the blocks regexp code and features, eventgough I get about two of
such requests per week.
It will also allow us to:
* Make that proposed admin theme a lot easier and nicer to code.
* Allow very fancy themes (i.e. show a banner on foo and bar only)
* Allow modules to easily check for its location (we now have loads of
if($_GET['q'] = foo) in code. They can now use an easy API.
* Do any other easy WhereAmI checks. We offer no such locator API atm.
The implementation is really easy, simple and changes hardly anything. 
Also, this patch will make a more regions implemtation a lot easier,
this patch can even be seen as the first step towards that.
Bèr


------------------------------------------------------------------------

April 3, 2005 - 20:58 : chx

Attachment: http://drupal.org/files/issues/block_regions.patch (2.92 KB)

More phpdoc. Proper CVS diff.


------------------------------------------------------------------------

April 3, 2005 - 22:25 : Dries

I have problems understanding the following sentence: "You may use this
function for anything that needs a node type or a URL matcher.". 
People not familiar with the function won't understand what is meant
with "a node type or a URL matcher".  I happen to understand this, yet
I don't understand what is meant with "anything"?  Is the documentation
for @return still current?  Do people understand what is meant with
"region"?  IMO, this function's PHPdoc is still somewhat
confusing/obscure.


------------------------------------------------------------------------

April 3, 2005 - 23:01 : chx

People not familiar with the function won't understand what is meant
with "a node type or a URL matcher".  [...] yet I don't understand what
is meant with "anything"? 
Anything is, well, anything. Sections module will most probably use
this to use different themes for different sections on the same site.
nodetype.module (not commited yet) uses this (and db_rewrite_sql) to
constrain certain pathes to certain nodetypes. For eg. you may have
your 'node' home page display only story type nodes. These modules will
store their blocks into custom regions, and issue a block_list to do
their magic. These won't display anything resembling a box. So the
functionality is really about checking whether the current page matches
a given set of paths and/or is of a certain node type.
Is the documentation for @return still current? 
Yes, it is, 
Do people understand what is meant with "region"?
I do not know. A region is a collection of blocks. Is this enough?





More information about the drupal-devel mailing list