Output Apparently Unavailable

Events happening in the community are now at Drupal community events on www.drupal.org.
Scott McCabe's picture

Since I'm at least neck deep in a project for our startup company, not having time to see if I can recreate my Content Profile problem on a fresh install as requested prior to expanding the issue queue, I followed the link to this group hoping for expedited salvation.

I have read the readme twice (not to mention explored the issue queue) and despite what it says, I cannot output anything Content Profile in comment.tpl.php, and really need to promptly remedy that.

Some basic facts about my Drupal install:

Drupal 6.13
Content Profile 6.x-1.0-beta4
Automatic Nodetitles 6.x-1.1

When I dsm($content_profile) in comment.tpl.php, I get a content_profile_theme_variables object for each comment containing a UID property with a value of 0 regardless of who posted the comment (two users posted, both not anonymous), and an empty _cache array.

Every other facet of Content Profile is apparently working perfectly. The registration form is inserting the form elements properly and inserting the submitted values into the database (so there is data ready to output).

If I can't resolve this output problem soon, I'm going to have to start building a custom module to select the data and output it myself (not good, given all of the other areas of this Web app. that I'm developing/designing).

Thank you in advance for any assistance provided.

Comments

A couple questions

bonobo's picture

1. Are you using the devel module? It contains some useful tools for themers, and could likely help you solve this problem.

2. RE:

If I can't resolve this output problem soon, I'm going to have to start building a custom module to select the data and output it myself (not good, given all of the other areas of this Web app. that I'm developing/designing).

Is this really better/faster than

see(ing) if I can recreate my Content Profile problem on a fresh install as requested

?

3. What exactly are you trying to achieve?

4. What happens when you use a core theme like Garland?

5. What other modules are you using? How many of these modules are custom built?

-----------------
FunnyMonkey
Click. Connect. Learn.
Using Drupal in Education

A couple answers (and a question)

Scott McCabe's picture
  1. Yes. Could you please be more specific in how I can use it to identify the problem area in the output chain?

  2. I'm confident that I know enough about Drupal, PHP, SQL, xHTML, and CSS to produce a competent result (see my answer to the next question to see that this would not be a complex mod.). While I certainly respect the need to do my part to help the open source community find and resolve issues (looking forward to having resources to focus on providing such help), I'm not confident that trying a fresh install is going to be productive in that whether the output shows up there or not does not promptly tell me how to fix my problem on the site I'm building.

  3. In my sole Profile content type, I created a set of CCK fields under a 'full name' group (field_name_first, field_name_last, etc.) I simply need to access the values of those fields for the relevant user in any given comment.

  4. Same result in Garland (UID = 0, _cache = empty array, nothing else).

  5. In sites/all/modules, there are 45 contrib. mods., and one basic custom "modmod" mod. with four functions using hook_form_FORM_ID_alter() (alter the comment form by making subject field required, alter title of search block, add a prefix and alter the submit value in user login block, and a handful of basically similar alterations to user register form) and one hook_menu_alter() function that simply alters the title of the user register page.

In my Zen sub-theme, my template.php file (including template-forms.php) overrides a handful of form elements set by contrib. mods. in hook_form_alter() (including unsetting $form['_author'] in comment form).

I could list all my installed contribs. here, and go further into my overrides, but I think a focus that can only come from a reply is needed at this time (in particular, how to travel back up the output chain to find where things are going wrong).

RealName module?

bonobo's picture

As to the specific source of your problem, I have no idea. There are a lot of places to look, and on the basis of the information you have provided, a variety of potential starting points. And with that said, starting with a clean install of content profile, your cck fields, and the comment module would be a great place to begin. The setup for this would be pretty basic:

Bring a site live; install content profile, CCK, token, devel, and autonodetitle. Import your profile content type, and there you go. This would probably take under an hour (30 minutes?) and would allow you to get a clearer sense of where the issue originates. This is how I would "travel back up the output chain to find where things are going wrong" -- by starting from the beginning and seeing where they stop going right. Without a clear indication of where the problem originates, all else is grasping at straws. You might get lucky, and you might use a lot of time in the process of trying to get lucky.

But it also sounds like the RealName module might get you where you need to go: http://drupal.org/project/realname -- of course, I have not tried this module, so I can't vouch for it from personal experience. But it's been around for a while, supports Content Profile, and has a stable point release for D6.

Cheers,

Bill


FunnyMonkey
Click. Connect. Learn.
Using Drupal in Education

RealName module not a fit here

Scott McCabe's picture

Luck is a prerequisite to promptly resolving my problem no matter how I troubleshoot it. Starting fresh and building up to my current site to find the problem could take a very long time, since there's a lot to build up to.

No one has chimed in pointing to the obvious 'Scott should be embarrassed for posting this discussion' solution (a mixed blessing), so in conjunction with switching to Garland not correcting it (negating the problem being in my theme), being the superuser doesn't correct it (negating the problem being a permission misconfiguration), and no one else apparently having this problem (making my modules combination a solid candidate), my troubleshooting will be:

  1. examine the Content Profile code from the moment it accesses the data from the database through the point of creating the $variable['content_profile'] to see if any other modules interfere for some reason.

  2. assuming I find no code conflicts with other modules, file an issue if I find a bug.

If this approach fails, I'm still on the fence between trying your starting fresh suggestion and using a custom mod. to grab the data (my decision rests with how quickly I can find the right database query) and sending it through Drupal's theme system to the $variables array (not to mention that I think my own mod. approach would be more fun :-).

RealName has already been installed, tried, uninstalled, since it does not give me the flexibility I need (no disrespect to the RealName module proponents). It would likely take me more time to adapt RealName to my needs than arranging and inserting the fields exactly where I need them in my site by working solely with Content Profile output.

Thank you again for your suggestions. I will report back if I find something that may interest this audience.

Got It

Scott McCabe's picture

After troubleshooting, I found that there is no module conflict or bug in Content Profile.

$content_profile is available in the template file. I used $profile = $content_profile->get_variables('profile'); there and successfully retrieved the fields.

However, the get_variables() method was not available in the corresponding template.php preprocess function, which is where I was trying to use it to grab and organize the real name prior to sending it to the template file as a single variable.

Once I moved the 'grab and organize' code into the template file, all worked fine.

However, since I was dealing with comments.tpl.php, the output produced the user's real name for every comment instead of the comment author's.

Here is my temporary solution (place in template.php comment preprocess function):

<?php
// Get author's user id.
$comment = $variables['comment'];
$author_uid = $comment->uid;

// Get node id for author's profile.
$nid_profile = db_result(db_query("SELECT nid FROM {node} WHERE uid=%d AND type='%s'", $author_uid, 'profile'));

// Get author's content profile
$profile = node_prepare(node_load($nid_profile));

// Structure real name.
$name_first = $profile->field_name_first[0]['value'];
$name_last = $profile->field_name_last[0]['value'];
if (!
$profile->field_name_middle[0]['value']) {
 
$name_middle = '';
}
else {
 
$name_middle = $profile->field_name_middle[0]['value'] . ' ';
}
if (!
$profile->field_name_suffix[0]['value']) {
 
$name_suffix = '';
}
else {
 
$name_suffix = $profile->field_name_suffix[0]['value'];
}
$name_nickname = $profile->field_name_nickname[0]['value'];
if (
$name_nickname) {
 
$name_first = $name_nickname;
}

// Assemble real name.
$real_name = $name_first . ' ' . $name_middle . $name_last . $name_suffix;
$variables['comment_author_real_name'] = check_plain($real_name);
?>

I dislike querying the database from template.php, and will eventually try moving the code to my custom module.

I welcome any suggestions for improving my code, or for a better solution altogether.

Profiles as nodes

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

Hot content this week