[buddypress-dev] Better way of doing this?

Martin martin at thrive-magazine.com
Mon Jun 23 20:14:17 GMT 2008


Andy,

This sounds great!

Are there plans to increase the functionality of the new functions so you
can catch URIs that don't have a username after the domain name (or is it
already implemented that way)? 

For example if I wanted to theme a group's moderation tasks I may want to
intercept a URI like:
http://buddypress.local/group_name/comment/edit/comment_id
And pass it to code in the current template directory.

Martin

-----Original Message-----
From: buddypress-dev-bounces at lists.automattic.com
[mailto:buddypress-dev-bounces at lists.automattic.com] On Behalf Of Andy
Peatling
Sent: Monday, June 23, 2008 12:21 PM
To: buddypress-dev at lists.automattic.com
Subject: Re: [buddypress-dev] Better way of doing this?

On 19-Jun-08, at 9:30 AM, Martin wrote:

> Motivated by seeing Andy's screen shots of the new theme he is  
> working on I have started work on my own BuddyPress compatible  
> theme, but I have hit a problem that I have managed to solve but it  
> required a change in the core Wordpress MU code, which I was trying  
> to avoid if at all possible.
>
> First some background, I am working on a website that is running  
> Wordpress MU in non virtual host mode, so the blogs are
www.domainname.com/blogname 
> , and want to allow for a user being an administrator on multiple  
> blogs, and a blog to have multiple authors. I decided that I wanted
www.domainname.com/members/username 
>  to show a user profile and list their blogs and
www.domainname.com/profile 
>  to show the current user. First problem is that because I am not  
> configured as a virtual host Wordpress MU tries to create a blog  
> called members or profile, I have managed to solve this by changing  
> a line in wpmu-settings.php from
> $blognames = array( 'page', 'comments', 'blog', 'wp-admin', 'wp- 
> includes', 'wp-content', 'files', 'feed' );
> To
> $blognames = array( 'page', 'comments', 'blog', 'wp-admin', 'wp- 
> includes', 'wp-content', 'files', 'feed', 'members', 'profile' );
>
> Is there a better way of getting Wordpress MU to allow this to go  
> through?

I've implemented some catch URI code based on Chris Taylor's work in  
the latest version in trunk. Basically, it works like this:

http://mydomain.com/username/[component_name]/[action_name]/ 
[action_vars]

So: http://buddypress.local/apeatling/profile/edit/group/1

The following globals will be set:

$current_component = 'profile'
$current_action = 'edit'
$action_variables = array ( 'group', 1 )

You can access these variables wherever you like and use them within  
your own custom template functions.

I'm using them to direct to custom templates using the new 'bp_uri()'  
function:

if ( $current_action == 'change-avatar' && $loggedin_userid ==  
$current_userid )
	bp_catch_uri( 'profile/change-avatar' );

Where 'profile/change-avatar' represents a folder and filename within  
the template directory.

This hopefully will allow BuddyPress to use a whole range of custom  
URL's whilst still using the default .htaccess file for an MU install.


>
> For those of you that may want to do the same thing I then modified  
> my .htaccess and added the following lines to it:
> RewriteRule ^.*/?members/(.*)/ /index.php?sn_action=member&sn_member= 
> $1 [L]
> RewriteRule ^.*/?profile/$ /index.php?sn_action=profile [L]
>
> I'm far from being a mod rewrite expert, so someone may be able to  
> suggest a better way of doing this?
>
> I then wrote a plug-in that looks for sn_action and includes a page  
> from the current template to display the information e.g.
>  function member_redirect() {
>   if (isset($_GET['sn_action'])) {
>         $action = $_GET['sn_action'];
>             switch($action) {
>           case 'member':
>         if (isset($_GET['sn_member'])) {
>           $sn_member = $_GET['sn_member'];
>           if($template = get_query_template('member')) {
>             include($template);
>             exit;
>           }
>         }
>             exit;
>           break;
> ...<snip>
>
> add_action('template_redirect', 'member_redirect');
>
> Again I am no expert at this there may be a better way?
>
> All that remains to be done is to add a member.php etc. to the home  
> template. You can then modify the default template to show all  
> author information for the blog, with links to their profiles,  
> instead of trying to figure out who's profile to show for the  
> current blog.
>
> It will also allow me to add template changes so that a user can  
> "follow" a blog, but be a "friend" to a user.
>
> Another problem I see with this method is the member URL is formed  
> using the login name of the user, I really don't want to make that  
> publically viewable, is there a way currently, or going to be a way  
> in the future that I can create a required field in XProfile that  
> should be unique across all users, so a user can enter what they  
> want to be used for their URL?
>
> I love where BuddyPress is going, and have enjoyed working on my own  
> theme for it, if any one wants more information on what I'm doing,  
> let me know,
>
> Martin
> _______________________________________________
> buddypress-dev mailing list
> buddypress-dev at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/buddypress-dev

_______________________________________________
buddypress-dev mailing list
buddypress-dev at lists.automattic.com
http://lists.automattic.com/mailman/listinfo/buddypress-dev



More information about the buddypress-dev mailing list