The theme system is supposed to accomodate include files, but there seems to be a bug in line 234 in function _theme_process_registry
It requires one to specify both 'file' and 'function' if you want to use an include file, rather than the function name being generated as normal.

Attached patch is one simple approach - use a 'include file' element instead to specify include files.

Comments

Crell’s picture

It's an API change, but it is a fully backward compatible one and makes the API cleaner for optimizing code. It breaks nothing, so I'm OK with it but also wouldn't be heart-broken if it doesn't go in.

merlinofchaos’s picture

Change this from 'include file' back to 'file' and then change the uses of 'file' that mean 'template' to 'template'. That'll create a bunch of clarity, and I approve of that.

ACtually, I'm ambivalent about 'file' vs 'include file'.

profix898’s picture

Regarding 'file' vs. 'include file'. We have an issue about .inc files and batches at http://drupal.org/node/169079. Its not really related, but maybe we can make the property consistent in menus, theme functions and batches!?

pwolanin’s picture

since the menu system uses 'file', I'd like to go with merlin's 'template' and 'file'.

Crell’s picture

'file' vs. 'template' sounds good and consistent to me. Would that also affect preprocessing functions? I suppose it would if it's read as "include this file before you do anything with this theme entity".

pwolanin’s picture

Actually - that's a very good question. It seems that a even a theme function with a template might need to specify an include file that contains the preprocess function? So both 'file' and 'template' may be set of the same theme function?

merlinofchaos’s picture

Yes -- 'file' could have meaning both ways, which is actually the bug that makes this need fixing and pushes it, to me, from an API change to a bugfix.

pwolanin’s picture

Status: Needs review » Needs work
StatusFileSize
new3.2 KB

ok - here's a starter patch to *look* at - changes theme.inc as described by Merlin. Allows both templates and functions to specify a file (an include file) as 'file' while a template file name is now 'template'.

pwolanin’s picture

Title: can't use include files for theme functions » both theme functions and templates may need include files
Status: Needs work » Needs review
StatusFileSize
new11.62 KB

full patch- obviously you need to rebuild the theme registry (I just deleted everything in {cache})

Initial testing seems to work fine.

dvessel’s picture

Status: Needs review » Reviewed & tested by the community

I didn't test every page load for each theme function but scanned through the registry. All the "files" point to .inc files and "template" to templates.. Also looked at each HOOK_theme() that used templated functions and it's all good.

So, marking as RTBC.

Crell’s picture

Looks OK from a read through, but I don't have time to apply and test right now. Remember that the a.d.o page for hook_theme will have to be updated!

dvessel’s picture

Status: Reviewed & tested by the community » Needs work

One thing that should be addressed in this patch are conditionally included files. The registry will only work for function/preprocessors that exist when going through its discovery process.

I had a problem before when I moved "template_preprocess_block_admin_display()" into block.admin.inc. (Was my first template conversion that shouldn't have been committed. :-)

It would be a minor addtion to include the "file" just to be on the safe side. I mentioned this to Merlinofchaos and he said it's okay.

dvessel’s picture

Status: Needs work » Needs review
StatusFileSize
new12.74 KB

Here it is to include any files when building the registry. Tested by moving the preprocess function back into block.admin.inc. Works like a charm.

The poll.module entries were off so I changed them too.

pwolanin’s picture

Tested this from install onwards - everything seems to work fine. I enabled all the modules touched by the patch and tested them as well.

Poll module still seems rather broken - but that's not caused or changed by this patch.

So, I think this is good.

merlinofchaos’s picture

Status: Needs review » Reviewed & tested by the community

With two solid tests this is good to go.

dries’s picture

Status: Reviewed & tested by the community » Fixed

I agree that this is an important change/fix. Committed to CVS HEAD.

Anonymous’s picture

Status: Fixed » Closed (fixed)