Hi, I was wondering if it's possible to alter this function in the blog module, so that it displays a custom field from the user's profile instead of the user name of the user: <?php function blog_view($node, $teaser = FALSE, $page = FALSE) { if ($page) { // Breadcrumb navigation $breadcrumb[] = array('path' => 'blog', 'title' => t('Blogs')); $breadcrumb[] = array('path' => 'blog/'. $node->uid, 'title' => t("@name's blog", array('@name' => $node->profile_displayName))); $breadcrumb[] = array('path' => 'node/'. $node->nid); menu_set_location($breadcrumb); } return node_prepare($node, $teaser); } ?> Any help would be great! Sarah
Yes, you can use hook_view() (the code from the blog module is an implementation of hook_view).
http://api.drupal.org/api/function/hook_view/5
You just create the breadcrumb array the way it does below, replacing the appropriate element with the custom field data. I'm not sure if custom fields become part of the $user object, so you might have to query the database to get the field you want. For instance, if you were using the Profile module, you would need to query profile_fields and profile_values to get what you want and then replace the user name with the custom field in the $breadcrumb array.
Steve
Sarah.Vardy@student.griffith.edu.au wrote:
Hi,
I was wondering if it's possible to alter this function in the blog module, so that it displays a custom field from the user's profile instead of the user name of the user:
|<?php function blog_view($node, $teaser = FALSE, $page = FALSE) { if ($page) { // Breadcrumb navigation $breadcrumb[] = array('path' => 'blog', 'title' => t('Blogs')); $breadcrumb[] = array('path' => 'blog/'. $node->uid, 'title' => t("@name's blog", array('@name' => $node->profile_displayName))); $breadcrumb[] = array('path' => 'node/'. $node->nid); menu_set_location($breadcrumb); } return node_prepare($node, $teaser); } ?>|
Any help would be great!
Sarah
Hi Steve,
Thanks for your reply. I tired to change it to the following:
function getUserDisplayName($number) { $fieldId = 19; $result = db_query("SELECT p.value FROM {profile_values} p WHERE p.fid = $fieldId AND p.uid = $number"); while ($nameQuery = db_fetch_object($result)) { $displayName = $nameQuery; } return $displayName; } /** * Implementation of hook_view(). */ function blog_view($node, $teaser = FALSE, $page = FALSE) { if ($page) { // Breadcrumb navigation $breadcrumb[] = array('path' => 'blog', 'title' => t('Blogs')); $number = $node->uid; $breadcrumb[] = array('path' => 'blog/'. $node->uid, 'title' => t(getUserDisplayName($number) . "'s blog"); $breadcrumb[] = array('path' => 'node/'. $node->nid); menu_set_location($breadcrumb); } return node_prepare($node, $teaser); } But it still isn't working.
What am I doing wrong?
Sarah ----- Original Message ----- From: Steve Edwards killshot91@comcast.net Date: Tuesday, December 11, 2007 12:35 pm Subject: Re: [support] changing the display of the breadcrumb trail in blog module To: support@drupal.org
Yes, you can use hook_view() (the code from the blog module is an implementation of hook_view).
http://api.drupal.org/api/function/hook_view/5
You just create the breadcrumb array the way it does below, replacing the appropriate element with the custom field data. I'm not sure if custom fields become part of the $user object, so you might have to query the database to get the field you want. For instance, if you were using the Profile module, you would need to query profile_fields and profile_values to get what you want and then replace the user name with the custom field in the $breadcrumb array.
Steve
Sarah.Vardy@student.griffith.edu.au wrote:
Hi,
I was wondering if it's possible to alter this function in the
blog
module, so that it displays a custom field from the user's
profile
instead of the user name of the user:
|<?php function blog_view($node, $teaser = FALSE, $page = FALSE) { if ($page) { // Breadcrumb navigation $breadcrumb[] = array('path' =>
'blog', 'title' => t('Blogs'));
$breadcrumb[] = array('path' =>'blog/'. $node->uid, 'title' =>
t("@name's blog", array('@name' => $node->profile_displayName))); $breadcrumb[] = array('path' =>
'node/'. $node->nid);
menu_set_location($breadcrumb);} return node_prepare($node, $teaser); } ?>|
Any help would be great!
Sarah
-- [ Drupal support list | http://lists.drupal.org/ ]
Hey,
For anyone's who's interested I managed to get it working.
Here's the functions I changed/added to the blog module:
function getUserDisplayName($number) { $fieldId = 19; $result = db_query("SELECT p.value FROM {profile_values} p WHERE p.fid = $fieldId AND p.uid = $number"); while ($nameQuery = db_fetch_object($result)) { $displayName = $nameQuery->value; } return $displayName;
}
/** * Implementation of hook_view(). */ function blog_view($node, $teaser = FALSE, $page = FALSE) { if ($page) { // Breadcrumb navigation $breadcrumb[] = array('path' => 'blog', 'title' => t('Blogs')); $tmpnumber = array_sum(array($node->uid)); $userDisplay = getUserDisplayName($tmpnumber); $breadcrumb[] = array('path' => 'blog/'. $node->uid, 'title' => t($userDisplay . "'s blog")); $breadcrumb[] = array('path' => 'node/'. $node->nid); menu_set_location($breadcrumb); } return node_prepare($node, $teaser); }
----- Original Message ----- From: Sarah.Vardy@student.griffith.edu.au Date: Wednesday, December 12, 2007 4:22 pm Subject: Re: [support] changing the display of the breadcrumb trail in blog module To: support@drupal.org
Hi Steve,
Thanks for your reply. I tired to change it to the following:
function getUserDisplayName($number) { $fieldId = 19; $result = db_query("SELECT p.value FROM {profile_values} p WHERE p.fid = $fieldId AND p.uid = $number"); while ($nameQuery = db_fetch_object($result)) { $displayName = $nameQuery; } return $displayName; } /**
- Implementation of hook_view().
*/ function blog_view($node, $teaser = FALSE, $page = FALSE) { if ($page) { // Breadcrumb navigation $breadcrumb[] = array('path' => 'blog', 'title' => t('Blogs')); $number = $node->uid; $breadcrumb[] = array('path' => 'blog/'. $node->uid, 'title' => t(getUserDisplayName($number) . "'s blog"); $breadcrumb[] = array('path' => 'node/'. $node->nid); menu_set_location($breadcrumb); } return node_prepare($node, $teaser); } But it still isn't working.
What am I doing wrong?
Sarah ----- Original Message ----- From: Steve Edwards killshot91@comcast.net Date: Tuesday, December 11, 2007 12:35 pm Subject: Re: [support] changing the display of the breadcrumb trail in blog module To: support@drupal.org
Yes, you can use hook_view() (the code from the blog module is an implementation of hook_view).
http://api.drupal.org/api/function/hook_view/5
You just create the breadcrumb array the way it does below, replacing the appropriate element with the custom field data. I'm not sure if custom fields become part of the $user object, so you might have to query the database to get the field you want. For instance, if you were using the Profile module, you would need to query profile_fields and profile_values to get what you
want
and then replace the user name with the custom field in the $breadcrumb array.
Steve
Sarah.Vardy@student.griffith.edu.au wrote:
Hi,
I was wondering if it's possible to alter this function in
the
blog
module, so that it displays a custom field from the user's
profile
instead of the user name of the user:
|<?php function blog_view($node, $teaser = FALSE, $page = FALSE) { if ($page) { // Breadcrumb navigation $breadcrumb[] = array('path' =>
'blog', 'title' => t('Blogs'));
$breadcrumb[] = array('path' =>
'blog/'. $node->uid, 'title' =>
t("@name's blog", array('@name' => $node->profile_displayName))); $breadcrumb[] = array('path' =>
'node/'. $node->nid);
menu_set_location($breadcrumb); } return node_prepare($node, $teaser); } ?>|
Any help would be great!
Sarah
-- [ Drupal support list | http://lists.drupal.org/ ]