Hi,
I have added 4 computed fields to a node type (the "profile" node type, in case you wonder), and all of them have nearly the same code to compute their value. I'd like to create a function to write/debug the code only once, but where can I put it ? Would it work if I put it in the first field only ?
My computed fields are save in the database (they are used in views), if that matters.
Thanks, Xav
PS: please Cc: me on answers
I would say put the bulk of the code in a "helper" function, which can be called anything, and then the individual methods for the individual fields are just wrappers that call that function.
Oh sorry, meant to mention, don't put it in a field at all, but use computed field's ability to call code in a module.
HTH, Malks.
On 6:59 AM, Xavier Bestel wrote:
Hi,
I have added 4 computed fields to a node type (the "profile" node type, in case you wonder), and all of them have nearly the same code to compute their value. I'd like to create a function to write/debug the code only once, but where can I put it ? Would it work if I put it in the first field only ?
My computed fields are save in the database (they are used in views), if that matters.
Thanks, Xav
PS: please Cc: me on answers
On Thu, 2011-03-31 at 09:26 +1100, Anthony Malkoun wrote:
I would say put the bulk of the code in a "helper" function, which can be called anything, and then the individual methods for the individual fields are just wrappers that call that function.
Oh sorry, meant to mention, don't put it in a field at all, but use computed field's ability to call code in a module.
I see, thanks for the tip. Unfortunately I wanted the code to be editable by someone without FTP access, just by using the admin interface. Is there a way to do so ?
Thanks, Xav