[buddypress-trac] [BuddyPress] #2281: Missing Tags input field in Edit Forum Topic Page
buddypress-trac at lists.automattic.com
buddypress-trac at lists.automattic.com
Tue Feb 1 11:03:37 UTC 2011
#2281: Missing Tags input field in Edit Forum Topic Page
--------------------------+-----------------
Reporter: mercime | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: 1.3
Component: Groups | Version:
Resolution: | Keywords:
--------------------------+-----------------
Comment (by dubcheck):
Well, I came across the same issue but just adding tags is not sufficient
for my scenario. Please review this - it's a patch to allow adding,
removing and changing tags for a forum topic. (These two code snippets are
all you need, none of the other patches is required.) I copied some
context to allow orientation in the files, all changes are between 'patch'
and 'end patch' comments.
First add this to your template 'groups/single/forum/edit.php':
{{{
<textarea name="topic_text" id="topic_text"><?php bp_the_topic_text()
?></textarea>
<!-- 2011-01-18 enbiz Gerd Stammwitz: Patch to edit topic tags -->
<?php
// Get list of existing tags for this topic
$arrayOfTags=bb_get_topic_tags(bp_get_the_topic_id());
$tags="";
foreach ($arrayOfTags as $tag){$tags.=($tags==""?"":", ").$tag->name;}
?>
<label for="topic_tags"><?php _e( 'Tags (comma separated):', 'buddypress'
) ?></label>
<input type="text" name="topic_tags" id="topic_tags" value="<?php print
$tags; ?>" />
<p></p>
<!-- End Patch -->
<?php do_action( 'bp_group_after_edit_forum_topic' ) ?>
}}}
Then you have to patch 'plugins/buddypress/bp-groups.php':
{{{
function groups_screen_group_forum() {
// skipped ..
if ( !groups_update_group_forum_topic( $topic_id, $_POST['topic_title'],
$_POST['topic_text'] ) )
bp_core_add_message( __( 'There was an error when editing that topic',
'buddypress'), 'error' );
else
bp_core_add_message( __( 'The topic was edited successfully',
'buddypress') );
// -- 2011-01-18 enbiz Gerd Stammwitz
// -- Patch: Added Functionality to save topic tags
if (isset($_POST["topic_tags"]))
{
// Remove ALL tags from topic
bb_remove_topic_tags($topic_id);
// Add tags from input field
bb_add_topic_tags($topic_id,$_POST["topic_tags"]);
}
// End Patch
do_action( 'groups_edit_forum_topic', $topic_id );
}}}
The first snippet adds an input field to your edit form and fills it with
the currently set tags. The second code is a patch for the save handler
(which is triggered when you save your tags): it removes all current tags
and sets the (new) tags from the input field.
Please add this functionality (not necessarily this code) to BP - it is
really important!
--
Ticket URL: <https://trac.buddypress.org/ticket/2281#comment:12>
BuddyPress <http://buddypress.org/>
BuddyPress
More information about the buddypress-trac
mailing list