Hi,

firstly thanks for a great and very useful module. I was wondering wether there was any way of retrieving the node object of the node currently being processed. I read in another older discussion that this was already implemented for the 6-2 branch, but I can't seem to find it. My $customfilter variable is completely empty. Is there a way to do this?

Thanks in advance

Dave

Comments

avpaderno’s picture

It was added, but then somebody made me notice a filter should never access data contained in the node object, and I removed the code to handle that.

To handle data from a node, the module should implement a different hook, and it would not be a filter anymore.
I will think if it is the case to implement such code.

huesforalice’s picture

Status: Active » Closed (fixed)

Ok thanks for the information! Will have to think of another way then.

Dave

avpaderno’s picture

Title: Retrieving Node Object (Or Node ID) in Rule Replacement Text » Add the possibility to retrieve node data from a filter
Version: 6.x-2.0-beta7 » 6.x-2.x-dev
Component: User interface » Code
Category: support » feature
Status: Closed (fixed) » Active

What I meant is that the module should implement two different types of filters, one of which would be able to use any data it gets from the node object. The two types of filters would be implemented through two different hooks, but that is an implementation detail; in any case they would be filters the same.

There are some details that I need to verify.
In example, if the filter would allow to replace —title— with the node title, the filter description needs to appear in the input format description, otherwise users will not know they can use —title— any times they are referring to the title; the hook that effectively does the work needs to verify if the node passed to it is one where the filter is enabled.
It's not something difficult to do, and I think it can be done.

Anonymous’s picture

Status: Active » Closed (won't fix)

Filters are also used for comments; if the module would list the filters that are only used for the node content, that would be confusing for the user.

It seems there is no way to do it.

NoRandom’s picture

Sorry for bumping this old thread.

Do you know something similar to custom filter wich could access to node/comment information? I'd like to modify a custom filter depending on the node type.

Maybe it could be done using "cck computed field", regex and some php manipulation but I'd like to know if there is anything a little bit simpler.

Regards.

PS.- I've just noticed "cck computed field" doesn't work for comments so this way won't work for them.

Anonymous’s picture

Input filter modules don't get any information about the context in which they are invoked, with the exception of the text they need to alter; this means such modules are not able to understand if they are invoked to alter the node content, or the text of a comment.

If you need to alter the content of a node basing on information taken from the node self, you should implement hook_nodeapi() (Drupal 6), or hook_comment() if the purpose is to alter the content of a comment basing on information taken from the comment.

NoRandom’s picture

Thanks, kiam, I'll try to do that.