[development] Block visibility only in module pages

Cameron Eagans cweagans at gmail.com
Thu Jan 28 15:28:45 UTC 2010


An even better practice would be to spend some time upgrading to Drupal 6,
and soon! ;)
-----
Cameron Eagans
Owner, Black Storms Studios, LLC
http://www.blackstormsstudios.com


On Thu, Jan 28, 2010 at 6:13 AM, ktt <kestutis98 at yahoo.com> wrote:

> Thank you, it works!
> I found, that Drupal recommends to use named arguments with menu callback
> functions as a better practice:
> http://api.drupal.org/api/function/arg/5
>
> Regards,
> Ktt
> --- On Wed, 1/27/10, William Smith <william.darren at gmail.com> wrote:
>
> > From: William Smith <william.darren at gmail.com>
> > Subject: Re: [development] Block visibility only in module pages
> > To: development at drupal.org
> > Date: Wednesday, January 27, 2010, 8:47 PM
> > I don't recall if there is a cleaner way
> > to do this in Drupal 5, but as a kludge in your
> > 'view' case you could check the path and only return
> > the block array if you are on an admin page.
> >
> > For example:
> >
> >
> > case 'view':
> >   $blocks['subject'] = t('Create email
> > contacts');
> >   $blocks['content'] = t('My email contact
> > content');
> >   if (arg(0) == 'admin') {
> >     return $blocks;
> >
> >   }
> >
> > On Wed, Jan 27, 2010 at 1:18 PM,
> > ktt <kestutis98 at yahoo.com>
> > wrote:
> >
> > Thank you for exact answer.
> >
> > I use DRUPAL 5.21, and it seems, this option
> >
> > isn't available:
> >
> > http://api.drupal.org/api/function/block_example_block/5
> >
> >
> >
> > My code didn't work for admin/* :
> >
> >
> >
> > function EmailM_block($op='list' , $delta=0,
> > $edit=array()) {
> >
> >   switch ($op) {
> >
> >     case 'list':
> >
> >       $blocks[0] = array(
> >
> >         'info'       => t('Example:
> > EMAIL M'),
> >
> >         'status'     => TRUE,
> >
> >         'weight'     => 0,
> >
> >         'visibility' => 1,
> >
> >         'pages'      =>
> > 'admin/*',
> >
> >       );
> >
> >       return $blocks;
> >
> >     case 'view':
> >
> >       $blocks['subject'] = t('Create email
> > contacts');
> >
> >       $blocks['content'] = t('My email
> > contact content');
> >
> >       return $blocks;
> >
> >   }
> >
> >
> >
> > }
> >
> >
> >
> > Regards,
> >
> > Ktt
> >
> >
> >
> > --- On Wed, 1/27/10, William Smith <william.darren at gmail.com>
> > wrote:
> >
> >
> >
> > > From: William Smith <william.darren at gmail.com>
> >
> > > Subject: Re: [development] Block visibility only in
> > module pages
> >
> > > To: development at drupal.org
> >
> > > Date: Wednesday, January 27, 2010, 6:44 PM
> >
> > > Yes, you should be
> > able to do this from the
> >
> > > module code.  See the block_example code at
> http://api.drupal.org/api/function/block_example_block/6
> >
> > >
> >
> > >
> >
> > > Note the 'pages' array element (in the example
> > code
> >
> > > it is specified as 'node/*').  In your case,
> > you
> >
> > > would want to set this to
> > 'admin/build/modules'
> >
> > >
> >
> > > Best,
> >
> > > William
> >
> > >
> >
> > >
> >
> > > On Wed, Jan 27, 2010 at 11:33 AM, ktt <kestutis98 at yahoo.com>
> >
> > > wrote:
> >
> > >
> >
> > > Hello,
> >
> > >
> >
> > >
> >
> > >
> >
> > > Is it possible to define block to show only in module
> >
> > > pages?
> >
> > >
> >
> > > I would like to define that in module code - is it
> >
> > > possible?
> >
> > >
> >
> > >
> >
> > >
> >
> > > Thank you in advance,
> >
> > >
> >
> > > Ktt
> >
> > >
> >
> > >
> >
> > >
> >
> > >
> >
> > >
> >
> > >
> >
> > >
> >
> > >
> >
> > >
> >
> > >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/development/attachments/20100128/1dababb7/attachment-0001.html 


More information about the development mailing list