Closed (works as designed)
Project:
Views Custom Field
Version:
6.x-1.0
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
26 Dec 2009 at 03:42 UTC
Updated:
12 Jun 2012 at 12:13 UTC
Hello,
When using 'customfield: PHP code' and declaring a function in the php code, I get the following error:
Fatal error: Cannot redeclare child_level() (previously declared in /var/www/jdbi/sites/all/modules/views_customfield/includes/views_customfield_handler_field_phpcode.inc(118) : eval()'d code:10) in /var/www/jdbi/sites/all/modules/views_customfield/includes/views_customfield_handler_field_phpcode.inc(118) : eval()'d code on line 23
If I put the function in a separate file a do a include of the file, I get the same error. Using the same code somewhere else in views, for example in the header, it works as it should
Comments
Comment #1
Isostar commentedComment #2
infojunkieThe custom field code is evaluated once for each row in the view result, as opposed to the view header which is only evaluated once. I suggest placing your function in your own module.
Comment #3
chitraar commentedhow to include user defined .inc file in a tpl file.
Comment #4
bis20 commentedJust do following Technic:
Do it That way:
1- create your custom module [testmodule]
2- create testmodule.install file with following syntax:
3- Create testmodule.code.inc file & place your Custom function on it.
4- goto your view and place the following code in Header of view:
5- finally check the loading of include file in your custom php field by following function :
do not forget to flush caches.
B&R
Bis20