[support] how to use the 2 blocks in single module
Jonathan Hedstrom
jhedstrom at opensourcery.com
Tue Jun 24 18:14:52 UTC 2008
bharani kumar wrote:
> Dears i want to use the two blocks in a single module this is my code ,
>
> in 2 block are displayed in the blocks setting place,
>
>
> i enable both , its not displaying,
>
> Any idea..
>
> <?php
> // $Id$
> /**
> * Implementation of hook_block().
> *
> * Displays the most recent (x) blog titles on the user profile page.
> (x) is set in block configuration admin section.
> */
> function ptHeadlines_block($op = 'list', $delta = 0, $edit = array()) {
> global $user;
> switch ($op) {
> case 'list':
> $block[0]['info'] = t('More Headline ');
> $block[0]['title'] = t('More Headline ');
>
> $block[1]['info'] = t('Top Headline');
> $block[1]['title'] = t('Top Headline');
Here you are defining $delta. The "More Headline" block is $delta == 0,
and the "Top Headline" block is $delta ==1
> [snip]
> //this is block for top Headlines
>
> if (user_access('access content') && $delta == 0 &&
> arg(0)=='user') {
You need to change this line to check for $delta == 1
A more common approach for the 'view' operation is to use a switch on
$delta:
switch ($delta) {
case 0:
// do stuff for first block
break;
case 1:
// do stuff for second block
break;
}
return $block;
Cheers,
Jonathan
--
Jonathan Hedstrom OpenSourcery
http://opensourcery.com Technology for Good
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: OpenPGP digital signature
Url : http://lists.drupal.org/pipermail/support/attachments/20080624/69225524/attachment-0001.pgp
More information about the support
mailing list