Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
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
Comment #1
DrupalNovice CreditAttribution: DrupalNovice commentedConfirmed 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:
Comment #2
fagohm, this shouldn't be the case. Anyone else has troubles with that?
Comment #3
DrupalNovice CreditAttribution: DrupalNovice commentedOK..it worked for me though..
Thanks for a great module!
Comment #4
fagoComment #5
Kristi Wachter CreditAttribution: Kristi Wachter commentedReopening, 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!