[development] access to $node in hook_fillter()

Gordon Heydon gordon at heydon.com.au
Sun Jul 16 12:20:57 UTC 2006


Hi,

Gabor Hojtsy wrote:
> On Sat, 15 Jul 2006, [iso-8859-1] B�r Kessels wrote:
> 
>> Does anyone know a trick (or something I shouldve read, but did not read)
>> about how to get acces to $node objects in hook_filter?
>>
>> My filters do not alter anything in that object, but the filters /do/ 
>> need
>> some parameters in that object.
>>
>> As far as I can see, _filter only receives a 'stupid' text-chunk, but 
>> I cannot
>> beleive that we designed it that stupid and never pass more 
>> information to he
>> filters. Its just that I cannot find the wheres, hows and whens.
> 
> I tried to get a patch in, which would pass the node along. But filters 
> are not only used for node text. They are used for the site mission, 
> node add page help texts and such.
> 
> The answer to this question then was that I should use nodeapi view to 
> do node based filtering. This is what I do.

I took a look at this patch, and I concluded that the passing of other 
information needed to more generic. So not so much just being able to 
pass a node.

One thing that I would like to see is targeted filters so that you can 
have a filter which will only be applied to nodes, and other filters 
which will be applied to other types of data which is being filtered.

I was actually looking to using the filtering for the E-Commerce emails, 
but it was just too node centric.

Doing this then you can set up to allow the passing of an array of 
parameters which could then used by the filter. In the case of the php 
filter you could extract() the array and use all the parameters as local 
  values.

Also it means that filters could be targeted, ie. can be used for nodes 
or any other type of data, or global like what there is now, and not 
care what the data is.

Also this will change the filter_tips and only show filters which are 
applicable to the type of data that is being filtered.

I plan on doing this one day when I have time. It will make the 
filtering system a lot more powerful.

Gordon.


More information about the development mailing list