Hi!

The Docs (README.TXT) provides me this code:

// Just output the title of the content profile of type 'profile'
    // If there is no such profile, it will output nothing.
    echo $content_profile->get_variable('betel_profil', 'title');

The funny thing is that when I test this, all I get is:
Fatal error: Call to a member function get_variable() on a non-object in C:\...\drupal\sites\all\themes\mytheme\user-profile.tpl.php on line 55

I'm calling this from my user-profile.tpl.php file (as the README states you can do).

What's the problem here?

Comments

DrupalNovice’s picture

Component: Base module » Documentation
Status: Active » Needs review

Confirmed as a bug in the documentation.

You need to start a new object of the content_profile_theme_variables class in order to get the code in the README.TXT
working, like so:

$content_profile = new content_profile_theme_variables($uid);
fago’s picture

Title: A bug? » Troubles with the theme helper
Priority: Critical » Normal

hm, this shouldn't be the case. Anyone else has troubles with that?

DrupalNovice’s picture

OK..it worked for me though..

Thanks for a great module!

fago’s picture

Category: bug » support
Status: Needs review » Closed (won't fix)
Kristi Wachter’s picture

Version: 6.x-1.0-beta3 » 6.x-1.0
Category: support » bug
Status: Closed (won't fix) » Active

Reopening, since I just experienced this as well. (Also, I changed it to a bug report, since a Fatal Error seems like a bug to me.)

I was getting this error:

Fatal error: Call to a member function get_variables() on a non-object in public_html/sites/all/themes/mysite/node-article.tpl.php on line 51

Line 51 is this:

$user_profile = $content_profile->get_variables('profile');

This is a node template, so according to the README, $content_profile should be available:

The $content_profile variable is available in the page, node, comment, user_name,
user_profile, user_signature, search_result and some other templates.

I've added the extra line to my node template:

$content_profile = new content_profile_theme_variables($uid);

although I agree that, as I understand the README, this shouldn't be necessary, and it seems like a possible performance hit.

To complicate things, I'm pretty sure the fatal error was intermittent. I definitely saw it several times, but I don't think it always appeared ... which made me wonder whether it might be related to the incorrect cache use issue.

Thanks!