.:: Hello ::.
Need some help changing a small piece of code from (the abandoned) og_forum.module file.
All I want to do is change the way a URL is created:
>
/**
* Implementation of hook_og_create_links().
*/
function og_forum_og_create_links($group) {
global $user;
$links = array();
// Get group's forum
$forum = og_forum_get_forum($group->nid);
if ($forum) {
$links[] = l(t('Forums'), "og_forum/$forum/$group->nid", array('title' => t('View group forum discussions.')));
}
return $links;
}
I want to change "og_forum/$forum/$group->nid" to "forums/GROUP-NAME-HERE". I've tried to fetch the group name using everything I know: $group->nid, $group->name, $group->title, none which are correct at fetching the group name in the correct URL format (dashes between words).
Be advised that I'm using clean URLs and the Pathauto module. That's not the issue. What I'm after here is just how to "fetch" the current group name the user is currently in, from within the og_forum.module file.
Any help would be greatly appreciated, thanks in advance...
Comments
print_r() is your friend
Since I don't know anything about the module in question, here's a handy PHP tip.
http://us2.php.net/manual/en/function.print-r.php
Use print_r() to reveal the full structure of any array or object. So, in this case, do
This will reveal all the elements defined in $group. (And their values.)
It is often best to wrap this in
<pre>tags for easier reading.Note: This is DEBUGGING code. Use it to find the structure, then remove it.
--
http://ken.blufftontoday.com/
http://new.savannahnow.com/user/2
Search first, ask good questions later.
a little moreplease?
I know I have used this before, but it was difficult because I place it in a .tpl file. Can I place it inside the body of the node and sumbit as PHP? Will it cause any damage, and work? (The 2 requirements I suppose :)
One more thing
Thanks for the tip. I got it to work and I saw that
$group->pathwould do the trick.BUT it led me into another problem I hope you could help me with.
$group->pathis only available to users with "administer url aliases" (path.module) permission.How do I make
$group->pathavailable to all roles without giving all roles that permission? Obviously I don't want all roles being able to change my url aliases :)Thanks again
where to place print(r)
Can you help me understand where to put that php code?
Sure
I got it to work in my situation by inserting it as you see above. Be advised that you will get different outputs for different roles and their permissions. As in my question above, I found the perfect element of
$group->pathbut it's not available to all roles and therefore, useless.If anyone is interested I did get my URL to work with
forum/$forum. I don't see exactly how :). You would think you would get an output of something like "/forum/69" but I get "/forums/group-name", just like I wanted. I don't understand fully why but oh well. Drupal is awesome...