#7485 closed enhancement (fixed)
Allow bp_get_group_permalink() to produce HTML links.
Reported by: | dcavins | Owned by: | dcavins |
---|---|---|---|
Milestone: | 2.9 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Groups | Keywords: | has-patch |
Cc: | dcavins |
Description
I believe there's a use-case for a convenience function that outputs a group's permalink as HTML, like:
<a href="<?php bp_group_permalink(); ?>"><?php bp_group_name(); ?></a>
sort of like bp_core_get_userlink()
.
We can get the convenience without adding a new function by adding a parameter to bp_get_group_permalink()
as I've done in the first patch.
Thanks for your feedback!
Attachments (3)
Change History (21)
#1
@
7 years ago
+1 Is it better though that we use the existing get function, is this meant to echo a complete link, would not a dedicated function be better?
#2
@
7 years ago
- Owner set to dcavins
- Status changed from new to accepted
I was thinking along the lines of bp_core_get_userlink()
which can return a url or a formatted link.
https://buddypress.trac.wordpress.org/browser/branches/2.8/src/bp-members/bp-members-functions.php#L498
In this case, the default behavior of bp_get_group_permalink()
is left intact, the second parameter allows the new behavior.
This ticket was mentioned in Slack in #buddypress by hnla. View the logs.
7 years ago
#4
@
7 years ago
- Keywords dev-feedback removed
A separate function seems better to me. The fact that bp_core_get_userlink()
can return an unformatted URL seems like a historical accident - it just becomes a wrapper for bp_core_get_user_domain()
.
Maybe bp_get_group_link()
or something like that?
#5
@
7 years ago
Thanks @hnla and @boonebgorges for your feedback. I'm attaching a new patch that leaves bp_get_group_permalink()
unchanged and adds a new function as suggested: bp_get_group_link()
.
Is this a useful template function, or is this one of those things that is no big deal to build when you need it, so there's no need for a dedicated function? I'm OK either way.
Thanks again for looking at the first patch.
#6
@
7 years ago
was going to ask whether this name was right for an echo type function but see there is one bp_group_link()
:)
I think it never hurts to have these? Yes one can build quite easily but still nice to save a little time when pressed with 1001 other things to get done.
#7
@
7 years ago
As a rule, if there are more than 2 places in BP where we could immediately put the new function to use (by swapping out what is currently concatenated), then it's probably a good move. I haven't looked, but I assume that there's many more than two places for this specific function.
#8
@
7 years ago
Those are good points. I'll attach a diff that would update a handful of existing instances in BP. Another popular form is creating a link using the group photo instead of the group name.
Thanks again for taking the time to look at this and respond.
#9
follow-up:
↓ 11
@
7 years ago
Just to over egg the pudding could we class the anchor:
<a class="%s-link" href="%s">%s</a>
or %s-home
If we wanted to really over egg the pudding we could allow class strings to be passed through :) but that would be gilding the lilly (today is a mixed metaphor day!)
#10
@
7 years ago
_I'll be ticketing Nouveau to update those replacement lines highlighted in templates._
#11
in reply to:
↑ 9
@
7 years ago
Replying to hnla:
Just to over egg the pudding could we class the anchor:
<a class="%s-link" href="%s">%s</a>
or%s-home
I'm happy to add whatever class name(s) you recommend, and think it's a good idea. Since these are general as well as specific, maybe we should add a couple, like a general group-home-link
as well as a specific %s-home
or %s-link
? (I'm assuming we'd use the group's slug as the identifier in the class string.)
Thanks!
#12
@
7 years ago
maybe we should add a couple, like a general group-home-link as well as a specific %s-home or %s-link? (I'm assuming we'd use the group's slug as the identifier in the class string.)
Absolutely to all the above, should be a generic link too & yes assumed the group slug would provide the dynamic portion.
Add an "html_link" parameter to bp_get_group_permalink().