My Albums: in members list count

Started by DD Admin, Feb 21, 2022, 09:54 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

DD Admin

Bookmarks Mode Edit To My Albums
Mod Assigned To: @diego

//Add to Subs At Bottom
//===================================
function checkBookmark()
{
    global $smcFunc, $context;
 
    // Enable only in these boards
    $boards = array(128);
 
    // Remove the button then
    if (!in_array($context['current_board'], $boards))
        return true;
 
    $request = $smcFunc['db_query']('', '
        SELECT id_member, id_topic
        FROM {db_prefix}bookmarks
        WHERE id_member = {int:current_member}
            AND id_topic = {int:current_topic}',
        array(
            'current_member' => $context['user']['id'],
            'current_topic' => $context['current_topic'],
        )
    );
    $rows = $smcFunc['db_num_rows']($request);
    $smcFunc['db_free_result']($request);
 
    return $rows;
}

Add To Display.Template.php
//Find
// Allow adding new buttons easily.
call_integration_hook('integrate_display_buttons', array(&$normal_buttons));
 
//Add Below
// Check if we want the bookmarks button
    if (!empty(checkBookmark()))
        unset($normal_buttons['bookmark']);

Modification.english.php (Section Below By Database Dreams)
//Modification.english.php
// Update
$txt['bookmarks'] = 'My Albums';
$txt['bookmark_list'] = 'My Albums';
$txt['bookmark_list_empty'] = 'You don\'t have any Albums at the moment. Add one by clicking \'Add My Album\' in topics.';
$txt['bookmark_open_window'] = 'Open in new window';
$txt['bookmark_delete'] = 'Delete selected Album';
$txt['bookmark_delete_success'] = '%1$s Albums were deleted successfully!';
$txt['bookmark_delete_failure'] = 'No Albums have been deleted.';
$txt['bookmark_add'] = 'Add To My Albums';
$txt['bookmark_add_success'] = 'The Album was successfully added to your My Albums!';
$txt['bookmark_add_exists'] = 'This album is already listed in your Albums!';
$txt['bookmark_add_failed'] = 'Failed to add the album to your Albums.';
$txt['permissionname_make_bookmarks'] = 'Create Albums for topics';
$txt['cannot_make_bookmarks'] = 'Sorry, you don\'t have permission to make Albums.';
 

DD Admin

#1
Original Mode Developed By @diego

Sources/Subs.php
Code ("Add at the end of the file") Select
// Count the bookmarks
function membersBookmarked($id_topic)
{
    global $smcFunc;

    $request = $smcFunc['db_query']('', '
        SELECT id_topic
        FROM {db_prefix}bookmarks
        WHERE id_topic = {int:id_topic}',
        array(
            'id_topic' => $id_topic,
        )
    );
    $rows_count = $smcFunc['db_num_rows']($request);
    $smcFunc['db_free_result']($request);

    return $rows_count;
}

Themes/default/Modifications.english.php
Code ("Find") Select
$txt['cannot_make_bookmarks'] = 'Sorry, you don\'t have permission to make Albums.';
Code ("Add Below") Select
$txt['bookmarks_total'] = '%d members have this album in their My Albums';
Themes/{theme}/Display.template.php
Code ("Find") Select
// Allow adding new buttons easily.
    call_integration_hook('integrate_display_buttons', array(&$normal_buttons));

Code ("Add After") Select
// Total Bookmarks
    $context['topic_total_bookmarks'] = membersBookmarked($context['current_topic']);

Code ("Find") Select
if (!empty($settings['display_who_viewing']))
Code ("ADD BEFORE") Select
// Bookmarks total
    if (!empty($context['topic_total_bookmarks']))
        echo '
                <div class="description">
                    ', sprintf($txt['bookmarks_total'], $context['topic_total_bookmarks']), '
                </div>';








Powered by EzPortal