Display User title in Story
SergeyK - January 24, 2008 - 03:46
| Project: | User titles |
| Version: | 5.x-1.x-dev |
| Component: | User interface |
| Category: | support request |
| Priority: | critical |
| Assigned: | SergeyK |
| Status: | closed |
| Issue tags: | Newbie |
Jump to:
Description
What is the simpliest way to add User title after the Author name in any kind of node (Story, for example)?

#1
Yes, I am having similar problem too. I could only view it on user profile, but not in nodes or comments.
I have read and followed instructions on readme.txt for displaying user title on nodes and comments but didnt work out.
Regards
#2
Have you tried following the instruction in the README.TXT file?
For the drupal 5 version it is this:
When installing this module, it won't appear to do anything at first. This is
because you need to modify your theme in order to place the output where
you like.
The function you need to call to get the data is
user_titles_get_user_title(). You may call this function either in
your template.php or in your node.tpl.php and/or your comment.tpl.php. It
is recommended that you place this in your template.php.
In template.php, in the function _phptemplate_variables, place this
piece of code under case 'node': and case 'comment':
<?phpif (module_exists('user_titles')) {
$vars['user_title'] = user_titles_get_user_title($vars['node']->uid);
}
?>
Note that $vars may be named something else, such as $variables in your
implementation. Note the variable in the function definition.
If you do not have a _phptemplate_variables() in your template.php
file, you may create one:
<?phpfunction _phptemplate_variables($hook, $vars = array()) {
switch ($hook) {
case 'node':
case 'comment':
if (module_exists('user_titles')) {
$vars['user_title'] = user_titles_get_user_title($vars['node']->uid);
}
}
return $vars;
}
?>
In your node.tpl.php and/or your comment.tpl.php, choose where you would like
the user title to appear, and place this code:
<?php if ($user_title): ?><div class="user-title"><?php print $user_title; ?></div>
<?php endif; ?>
There are other places you may wish a user title to appear, such as the user
profile page. Please see the drupal.org theming handbook for more information
on theming those; the additions you make will be materially the same as
these.
For the new 6 version (the dev version is almost up) it is this:
When installing this module, it won't appear to do anything at first. This is
because you need to modify your theme in order to place the output where
you like.
The function you need to call to get the data is
user_titles_get_user_title(). This module will automatically populate the
$user_title variable into your nodes and comments.
In your node.tpl.php and/or your comment.tpl.php, choose where you would like
the user title to appear, and place this code:
<?php if ($user_title): ?><div class="user-title"><?php print $user_title; ?></div>
<?php endif; ?>
Does this solve your issue?
Also, as a note, generally the 'active (needs more info)' status is when more information is required from the person that has raised the issue. You will generally get a quicker response if you just set it to 'active'.
#3
Closing due to inactivity.
Please feel free to reopen if this hasn't solved your problem.
#4
for drupal 6, exactly how do you call the function user_titles_get_user_title()
do you place the following in the template.php file?
function phptemplate_user_titles_get_user_title() {
if so, what goes here?
}
sorry in advance if the answer is an obvious one.
#5
I'm no expert on theming but I know that in Drupal 6 you don't use template.php files. They now use
.info files. See the first few paragraphs here: http://drupal.org/node/132442
For Drupal 6, you should just have to add the code that Agileware posted to your node.tpl and/or comment.tpl
files to get user titles to show up.
The problem I'm having is the title image doesn't show up in comments but the title name does show.
I can't get the images to appear.
#6
Resolved thx. Closing