How do I put categories/taxonomy on usernode??
public
group: Profiles as nodes
zzJames - Tue, 2007-01-16 19:10
I have tried to apply categories/taxonomy to usernodes but can't figure out how user can add categories
for example on my site the user zz_james can see his usernode editpage by going to the url
http://launchlab.org.uk/?q=node/31/edit
but how can I make a general page which I can hard-code into a menu for any user?
Sitewide tags: nodeprofile usernode registerprofile authorinfo


It doesn't look like
It doesn't look like usernode keeps users from editing their information on the usernode page. If so, you'll need to hack the usernode module.
Also, I'd need a login and password to look the link you gave.
sorry I am not being very clear....
yes I don't think the usernode keeps them from editing their usernode info.
I am just finding it hard to connect users to their usernode edit page URL
for example, if the user types in
www.site.com/?q=usernode
they see their very own specific usernode
but there seems to be no
www.site.com/?q=usernode/edit
only
www.site.com/?q=node/XX/edit
where XX is the node id of the usernode, so how do I connect a user to there usernode without a way to get that node id number from their log-in, I mean there must be a way if www.site.com/?q=usernode works!!!
ok. probably still unclear. thanks very much for responding
Usernode.module provides
Usernode.module provides this function to get the User's usernode ID:
<?php
/**
* Returns the id of the usernode of the user
* @param $user The user object or the users uid
*/
function usernode_get_node_id(&$user) {
static $history = array();
if(!is_object($user)) {
if (!$history[$user]) {
$history[$user] = db_result(db_query("SELECT nid FROM {usernode} WHERE uid = %d", $user));
}
return $history[$user];
}
if (!isset($user->node_id)) {
$user->node_id = usernode_get_node_id($user->uid);
}
return $user->node_id;
}
?>
cool.
Thanks.
:-)
Try this $usernode_id =
Try this
$usernode_id = usernode_get_node_id($user);print "<a href=\"?=node/$usernode_id/edit\">Edit your usernode</a>";
Alternatively this seems to work
another solution is to add this code to the implementation of hook_menu in usernode.module file.
(the function is called usernode_menu)
<?php
$items[] = array('path' => 'usernode/edit',
'callback' => 'usernode_edit_own_usernode',
'title' => t('Edit my usernode'),
'access' => $user->uid && user_access('edit own usernode'),
'type' => MENU_CALLBACK);
?>
and implement the function in usernode.module
<?php
function usernode_edit_own_usernode() {
global $user;
$node = usernode_get_node($user);
return node_form($node);
}
?>
that should make the url
www.yoursite.org/usernode/edit
bring up the usernode edit form.
I am not sure of any side effects of this yet, but it seems to work ok.
James
actually for my purposes
actually for my purposes this code was better
<?php
$items[] = array('path' => 'usernode/edit',
'callback' => 'usernode_edit_own_usernode',
'title' => t('Edit my profile tags'),
'access' => $user->uid && user_access('edit own usernode'),
'type' => MENU_CALLBACK);
?>
i.e. change the value of the title field.
** UPDATE ** that doesn't work, creates an error "you cannot change the title"
final point
this above method does work, and creating the callback in usernode_menu means the URL www.site.com/usernode/edit brings up the usernode edit page for easy adding of taxonomy, but if a menu item is created then the value of $node->title has to be kept to the username for the edited page to be submitted without causing problems, this can be achieved by adding the line
<?php// a bit of a hack for when using usernode editing linked from the menu
$node->title = $user->name;
?>
at line 380 of usernode.module
any improvements on these hacks welcome.
James