Friends 1.x

Legacy documentation for Friends 1.x.

The Friends:Group_Delete function allows group owners to permanently delete one of their groups. Simply link with the group ID in the URI to the template with the Friends:Group_Delete function code in it, or submit a POST form.

{exp:friends:group_delete} content {/exp:friends:group_delete}

Parameters

The following parameters are available for use:

dynamic=

dynamic="off"

This parameter is available to stop the loop from looking into the URI for a group ID.

friends_group_id=

friends_group_id="{segment_3}"

The Friends:Group_Delete loop automatically grabs the group ID from the URI, but this parameter is available to use, should you be doing something advanced.

Variables

The following variables are available for use:

friends_message

{friends_message}

This variable will output the success message or any errors upon loading the Friends:Group_Delete template.

Conditionals

The following conditionals are available for use:

failure

{if failure}Error!{/if}

This conditional shows its contents if the request action DOES NOT execute successfully.

success

{if success}Successful!{/if}

This conditional shows its contents if the request action executes successfully.

Form Fields

The following form fields are available for use:

ajax

<input type="hidden" name="ajax" value="yes" />

This form field tells the method to behave nicely with AJAX calls.

friends_group_id[]

<input type="checkbox" name="friends_group_id[]" value="{friends_group_id}" />

This form field is available to submit a POST form to the Friends:Group_Delete template, and also allows you to have a multiple check boxes within a list of groups so a group owner can select multiple groups and delete them.

Examples

The following code should be a complete example for using this function:

{exp:friends:group_delete}

    {if success}
        <h3>Successful!</h3>
    {/if}
    {if failure}
        <h3>Error!</h3>
    {/if}

    <p>{friends_message}</p>

{/exp:friends:group_delete}

Setup

Multiple Select from Groups List View

To implement this feature into a multi-select feature in a list page of groups a user owns, your code would look like this:

<form method="post" action="{path='friends/group_delete'}">

    <ul>
    {exp:friends:groups
        member_id="{logged_in_member_id}"
        dynamic="off"
        type="owner"
    }
        <li>
            <a href="{path='friends/groups'}/{friends_group_id}/">
                {friends_group_title}
            </a>
            <input type="checkbox" name="friends_group_id[]" value="{friends_group_id}" />
        </li>
        {if friends_no_results}
            <li>You currently do not own any groups.</li>
        {/if}
    {/exp:friends:groups}
    </ul>

    <p><input type="submit" name="submit" value="Delete Selected Groups?" /></p>

</form>

Single Group View

To implement this feature into a template for viewing a single group, your code would look like this:

{exp:friends:groups
    friends_group_id="{segment_3}"
}

    <h3>Group: {friends_group_title}</h3>
    <p>{friends_group_description}</p>

    {if friends_group_mine}
        <p>You own this Group.
        <a href="{path='friends/group_delete'}/{friends_group_id}/">Delete?</a>
    {/if}

{/exp:friends:groups}