*fixed: basic group map – help with Group Extension API
Edit* I came right
I wrote up a basic group map plug-in that I will further improve with options and stuff but I’m battling to get it to display the group map in the group subnav aka function display()
For now, in group admin options>edit details>map enter a lat/long like eg: -26.16777,28.04283 and save it
The map is currently being called in the group header ( line: 82 ) via
add_filter( 'bp_get_group_description', 'ggmap_show_map_in_header' );
I need help getting it to display at line: 215. Help would be greatly appreciated.
Plugin code: http://pastebin.com/XpZTxfDh
The code is a bit jumbled having played around a lot to try get this working.
@antonrsa Ill release it once it resembles something decent and I clean up the code a bit.
Will test it out tonight. Did you ever release a plugin where you can add more profile fields to groups such as address, website, etc?
activated and got this error when editing the details
`function BP_Group_Extension::edit_screen_save() must be over-ridden in a sub-class.`
is this when you try and go to group>admin>map cause I also get that error but cleaning it up.. Was thinking its better to not have a edit tab for one field and would rather incorporate it into the group details/ group creation step one..
For now edit the details via group>admin>edit details and look for the map field
I have a few, ie: address, website.. I had a look at how to release them to the wp respiratory but looked complicated so been avoiding it, once I have the group map working nicely Ill release them all.
Im working on adding directions and a street view, maybe should release it and have a forum so more experienced developers could help me out..
OK so I’m ganna incorporate a group address ( @antonrsa ) and call it in the group header but have it on the map creation step and in the map admin edit tab thing. The address wont affect the map as I can’t get the geo-coding working.. ( converting the address into co-ordinates ) will give it another try later on.
What I can’t get right is ( mebe @DJPaul or @boonebgorges could help ) saving the co-ordinates from the map admin edit screen: from lines 37 down ( http://pastebin.com/WnR6MTv6 )
I included the form and stuff for the create screen so you can see whats going on. My first time working with the group api so not to sure what to do and can’t find anything looking at existing plug-ins..
Had a quick look through your group extension and I saw a couple things. You shouldn’t call $bp->groups->new_group_id on the edit screen functions, cause it only exists when you create a group. That basically means that your edit_screen_save function uses $group_id and that variable hasn’t been declared, so it’s empty. Use $bp->groups->current_group->id and your group meta’ll get saved as expected.
One more thing. Your extension adds an edit/create page with only one input field. While this works it kind of clutters the admin area of a group, so it might be better to use an existing page, like the group settings and add that one option via an action hook. Just something to think about…
ta @travel-junkie that did the trick, ye I am ganna rather keep it using the groups_custom_group_fields_editable. At least i learned something in the process.
@travel-junkie is it possible to ‘hook’ to a plug-in’s edit/create page? say a edit/create page called additional info which could then call my group web site, phone number, ect.. as my 1st edit/create page is getting messy..
it’s possible if the plugin provides a hook, something like `do_action( ‘this_is_some_hook’ )`. I don’t really understand what you meant with your second sentence, though
ok say I have the group map plug-in, it has the group api for the edit/create screen ( lets call the slug “Group additional info” )
I also have a group website plug-in ( lest groups save and display a link to their site ) and a group phone number plug-in ( lets the groups save and display their phone number )
So the above plug-in’s could all be called in the “Group additional info” slug ( create/edit screens ) as they are related to that niche.
so then how/where could I add a hook so that the website and phone number plug-ins could ‘hook’ to the “Group additional info” slug ( create/edit screens )?
hope thats clearer
Alright, you just add a do_action call (like above) to one of the extensions and then attach a function to that action, like so: `add_action( ‘this_is_some_hook’, ‘your_function_name’ )`. You’ll also have to provide hooks in the functions where the data gets saved and hook into those to save the extra groupmeta. The WP codex has lots of info on actions and filters and is a good place to start.
@travel-junkie Im having a go but am confused..
Say I wanted this form ( http://pastebin.com/Yz0WwnK7 ) from the group website plugin to be displayed on the display tab of the map plugin, ( http://pastebin.com/60sBbQS1 )
I don’t see how I could hook to the display function with-in the group api.
Could you maybe provide an example with the above code to make it clearer. I know what its meant to to, but how to actually add the action for the display is whats unclear.
You need to provide the hook yourself, like so:
// some stuff
do_action( ‘my_custom_display_hook’ );
Then you attach something to it like so:
// some content
add_action( ‘my_custom_display_hook’, ‘my_custom_display_content’ );`
If you add this in a class context the action call would look like so and you would probably call it in the constructor:
`add_action( ‘my_custom_display_hook’, array( &$this, ‘my_custom_display_content’ ) );`
I guess that’s just an example, cause you wouldn’t want to add the option to the display function, but rather to the edit function.
ya I can see clearly now. Thanks for the help Travel-Junkie, much appreciated!
He is charging for the plugin:
Here’s my code, havnt looked at it since this topic but should work also check out this http://twitter.com/pressbuddies/statuses/10167203429093376:
You might want to remove the info window as its not doing much.. Hope its helpfull
@nit3watch That works great! Thanks!
Would you be interested in improving it a little more? I would like to, but probably could use a bit of help.
Two main things I would like to do:
1. Geocode the address so the use doesn’t need silly cords.
2. Display map of all groups.
Shouldn’t be too hard?
I tried “Geocode the address so the use doesn’t need silly cords” but thats beyond me..
Im stopped developing it as @msmalley ‘s gPress is around the corner ( http://gpress.my/blog/whats-happening-with-gpress-wheres-gpress-0-2-5/ )
- The topic ‘*fixed: basic group map – help with Group Extension API’ is closed to new replies.