I suppose you're adding content_profile_theme_variables class to variables list in content_profile_theme_registry_alter() to allow themers to get access to all of the node fields in their theme. It was quite interesting discovery for me, but nobody can use it in current implementations, as you add it after all other preprocess functions. Much better will be if you'll add it before others. My patch does this.

Also, the issue with content_profile_theme_variables is that it doesn't handle CCK fields. To get rendered CCK fields in node object, you need to pass node to drupal_render(). My patch also solves this.

Hope you'll find this patch useful.

Thanks!

Comments

fago’s picture

Status: Needs review » Needs work

Why shouldn't it be usable in the theme as it is now? If it's running as the last one, still it's variables are available to the theme.

Also the 'view' operation is already run, so users can render CCK fields themself. But yes, a separate helper might make sense to get the rendered CCK fields, or also the whole node body/teaser.

neochief’s picture

If it's running as is, the theme's preprocess function might be running before of it, so it doesn't have access to content_profile_theme_variables data. To avoid this, content_profile_theme_variables should be shifted to the beginning, so it's data available for each of later preprocess functions. Makes sense?

fago’s picture

Ah you mean for the preprocessor - ok makes sense.

neochief’s picture

Status: Needs work » Needs review

Okay, great! So, green light for commit?

fago’s picture

Status: Needs review » Needs work

This comment of #1 still applies:

Also the 'view' operation is already run, so users can render CCK fields themself. But yes, a separate helper might make sense to get the rendered CCK fields, or also the whole node body/teaser.

So the second hunk should go in separate helpers, but I suppose that's better another issue?

ckng’s picture

Second hunk should be another issue.

+1 for making $content_profile available for preprocessor.

Tested 1st hunk, work as expected but encounter infinite loop in get_variables() as it is calling all node template preprocessors if one of them happen to be a node template preprocessor.

In my case, added $conf['content_profile_extra_templates'] = array('user_picture'). user_picture happens to be in node template preprocessor list, when I try to access $content_profile in mytheme_preprocess_user_picture(), causes infinite loop WSOD.

Any thoughts on solving that?

ckng’s picture

Title: content_profile_theme_variables class should be attached before other preprocess functions » Making $content_profile available for preprocessor
Category: bug » feature
Status: Needs work » Needs review
StatusFileSize
new780 bytes

Change the title to better reflect the feature requested.
And the patch.

neochief’s picture

Status: Needs review » Reviewed & tested by the community
fago’s picture

Status: Reviewed & tested by the community » Needs work

Tested 1st hunk, work as expected but encounter infinite loop in get_variables() as it is calling all node template preprocessors if one of them happen to be a node template preprocessor.

hm, that's a serious problem. Until we have not found a proper solution for that, this is a no-go.

neochief’s picture

I can't catch this, can you describe detailed explanation, please? This patch works fine for 3 production sites for me.