By wickedbob on
I am trying to include a php file in my xtemplate and it does not seem to support this.
Is there a way to include an external php file directly in the xtemplate file or do I have to do this another way??
I am trying to include a php file in my xtemplate and it does not seem to support this.
Is there a way to include an external php file directly in the xtemplate file or do I have to do this another way??
Comments
There is a way
Many will tell you no, and that is the literal truth.
But there is away around the limitation at least for theme functions.
Say your theme is called example, then make a file called example.module and place in the module directory (note your theme name can not be the same as an existing module).
Now you can define theme functions with names like example_form_element where each function represents one of the many theme functions.
When ready, enable the "module" in the standard way.
Steve
There's a much better way
You can create a .theme file which will be used in addition to your template. For instructions, see my response to a request for PHP in xtemplate. There's more discussion in an issue where a user asked for the ability to have specific settings for a template.
This is a cleaner method than the .module hack, as this method was provided as part of the design of the current theming system.
EDIT: In 4.6 (a.k.a. CVS HEAD), you can slightly modify the code to make it simpler: