[support] can i hook a hook?

sebastian chedal inforazor at gmail.com
Fri Dec 10 18:06:11 UTC 2010


Sure, but I am also trying to learn how to work with modules. And using
"nodeasblock" + views to display the block seems kinda excessive, from a
code-simplicity perspective. Note that the new nodeasblock allows my content
admin to create a node AND place it in a predefined allowable region all on
their own from the node create/edit form; which is very handy. If I then
switch over to using views it defeats the point of the UX for the
content-admin.

On Fri, Dec 10, 2010 at 4:37 AM, Steve Kessler
<skessler at denverdataman.com>wrote:

> >From a different approach you may also just want to do this with views or
> PHP in a block and then you can customize anything you want without
> modifying a module.
>
> -Steve
>
> On Fri, Dec 10, 2010 at 2:12 AM, sebastian chedal <inforazor at gmail.com>wrote:
>
>> Thanks for your input, a few final questions about this before i give up
>> on trying to be fancy.
>>
>> 1. Is it not possible to "extend" a module with a custom module? Kinda
>> like if I was object programing? Or is hook_alter also required for this?
>>
>> 2. Is there any documentation I can read about making a module able to be
>> altered? What changes need to be made to allow this?
>>
>> 3. The nodeasblock.module does have several nodeasblock_*_form_alter
>> functions in it, is it somehow possible to preprocess some of these in a
>> theme or in a custom module, to add the new checkbox to toggle the link
>> being an href yes/no, and to then call a different function [from my custom
>> module] to accomplish this?
>>
>> Even if this last option is not the best solution [since I should probably
>> submit a patch to the module with the new checkbox as part of the module's
>> code], I'm curious to just know IF this is possible; so that when I
>> encounter more complicated problems, where what I need to do isn't
>> necessarily something that anyone else is ever going to want, and I still
>> want to make sure that if the module is updated that my extension to it
>> still (probably) works.
>>
>> While I appreciate your comment that I could just "leave it" I'm also
>> trying to learn here at the same time the more advanced aspects of drupal at
>> this stage since I am feeling ready for it! At the moment the best solution
>> I have is using PHP at the block-nodeasblock.tpl.php level to do a string
>> replace and strip the a href; but that feels like "wearing a bullet vest"
>> instead of just "getting rid of the gun".
>> :-)
>>
>> Until now I've been depending on a lot of other Drupal people to handle
>> bugs/features when they get hardcore but I really want to get a better
>> understanding for how to modify / extend / hook into and alter modules. It's
>> hard finding a lot of good information on this, so I'm always open to some
>> good links too!
>>
>> Thanks again!
>> Really appreciated.
>>
>> Sebastian.
>>
>>
>> On Thu, Dec 9, 2010 at 8:55 PM, Larry Garfield <larry at garfieldtech.com>wrote:
>>
>>> Unfortunately in that case it doesn't look like there's a way in.  You'll
>>> need
>>> to either hack the module or submit a patch back to the maintainer to
>>> make it
>>> more flexible.  The latter approach is generally preferred. :-)
>>>
>>> Or just decide that having the link there doesn't actually hurt anything
>>> so
>>> it's not worth fussing over.  That's also a viable option far more often
>>> than
>>> people realize.
>>>
>>> --Larry Garfield
>>>
>>> On Thursday, December 09, 2010 10:17:12 pm sebastian wrote:
>>> > Hi Larry,
>>> >
>>> > Thank you so much for replying to my query.
>>> >
>>> > So if my contrib module doesn't offer an _alter() (and it does not) my
>>> > only option is to hack the module? [or worse, use jquery to alter the
>>> > output]
>>> >
>>> > The module is question is nodeasblock and the function implements:
>>> >
>>> > nodeasblock_block ($op = 'list', $delta = 0)
>>> >
>>> > It makes theming decisions in it's operation, which I need to alter.
>>> > Namely it decides that the $node->title should be:
>>> >
>>> > l($node->title, 'node/'. $node->nid)
>>> >
>>> > I need to strip the <a href> since I don't want my block to be
>>> clickable
>>> > and lead to itself.
>>> >
>>> > In other words:
>>> >
>>> > 'subject' => l($node->title, 'node/'. $node->nid),
>>> >
>>> > will just become
>>> >
>>> >   'subject' => $node->title,
>>> >
>>> > I can hack the module, but that seems like a "no-no"
>>> >
>>> > Thanks!
>>> >
>>> > Sebastian.
>>> >
>>> > On 2010-12-09 8:04 PM, Larry Garfield wrote:
>>> > > Some hooks that offer definitions, like hook_menu(), will have a
>>> > > corresponding alter hook like hook_menu_alter().  There is no alter
>>> hook
>>> > > for hook_block(), though.  That said, there is an alter hook for all
>>> > > forms, hook_form_alter(). So if you're manipulating a form you may be
>>> > > able to do so that way.
>>> > >
>>> > > --Larry Garfield
>>> > >
>>> > > On Thursday, December 09, 2010 9:22:48 pm sebastian wrote:
>>> > >> Hello,
>>> > >>
>>> > >> Having a terrible time finding anything about this, and all I can
>>> find
>>> > >> on Drupal.org is the API for hooks, which doesn't really explain
>>> enough.
>>> > >>
>>> > >> My question is, if there is a contrib module with an implementation
>>> of:
>>> > >>
>>> > >> hook_block()
>>> > >>
>>> > >> such as:
>>> > >>
>>> > >> nodeasblock_block()
>>> > >>
>>> > >> How can I change the values inside of this function, without
>>> changing
>>> > >> the function directly?
>>> > >>
>>> > >> can I write something in template.php to catch the nodeasblock_block
>>> > >> hook and then change the values in it?
>>> > >>
>>> > >> Or do I need to change the nodeasblock module directly? perhaps
>>> adding
>>> > >> the feature as a full blown check box addition or just hack it??
>>> > >>
>>> > >> Thanks for any help you can provide me!
>>> > >>
>>> > >> kindly,
>>> > >>
>>> > >> Sebastian.
>>> --
>>> [ Drupal support list | http://lists.drupal.org/ ]
>>>
>>
>>
>> --
>> [ Drupal support list | http://lists.drupal.org/ ]
>>
>
>
>
> --
> Steve Kessler
> Owner and Lead Consultant
> Denver DataMan, LLC
> 303-587-4428
>
>
> --
> [ Drupal support list | http://lists.drupal.org/ ]
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/support/attachments/20101210/477ce24b/attachment-0001.html 


More information about the support mailing list