[support] changing the display of the breadcrumb trail in blog module
Sarah.Vardy at student.griffith.edu.au
Sarah.Vardy at student.griffith.edu.au
Thu Dec 13 01:29:20 UTC 2007
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 at 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 at 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 at 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 at 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 at 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/ ]
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/support/attachments/20071213/bd92181d/attachment.htm
More information about the support
mailing list