[ABD] "Like" Mod

Any abandoned MODs will be moved to this forum.

WARNING: MODs in this forum are not currently being supported or maintained by the original MOD author. Proceed at your own risk.
Forum rules
IMPORTANT: MOD Development Forum rules

WARNING: MODs in this forum are not currently being supported nor updated by the original MOD author. Proceed at your own risk.
tridion
Registered User
Posts: 5
Joined: Wed Jan 12, 2011 11:57 am

Re: [DEV] "Like" Mod

Post by tridion » Wed Jan 12, 2011 12:01 pm

rizfield wrote: my forum is waiting for your mod.. :)
My forum too. Keep going!

(btw, ajax updating without page reloading would be nice when click 'like' button. ;))

User avatar
digioz
Registered User
Posts: 297
Joined: Thu Feb 05, 2004 9:20 pm
Location: Chicago, IL
Name: DigiOz Multimedia
Contact:

Re: [DEV] "Like" Mod

Post by digioz » Wed Jan 12, 2011 2:51 pm

tridion wrote:
rizfield wrote: my forum is waiting for your mod.. :)
My forum too. Keep going!

(btw, ajax updating without page reloading would be nice when click 'like' button. ;))
Not a bad idea. Maybe for future versions, once the basic coding is done. ;)
DigiOz Multimedia
http://www.digioz.com

User avatar
digioz
Registered User
Posts: 297
Joined: Thu Feb 05, 2004 9:20 pm
Location: Chicago, IL
Name: DigiOz Multimedia
Contact:

Re: [DEV] "Like" Mod

Post by digioz » Wed Jan 12, 2011 11:31 pm

Here are the first draft of the changes for Memberslist page:
  • Open the file ./styles/prosilver/templage/memberlist_view.html
  • Find the following code:

    Code: Select all

    </form>
    
    <!-- INCLUDE jumpbox.html -->
    
  • Above it, add the following:

    Code: Select all

    <div class="panel bg1">
    	<div class="inner"><span class="corners-top"><span></span></span>
    
    		<h3>{L_LIKE_PROFILE_HEADER}</h3>
    
    		<!-- INCLUDE likedlist_profile.html -->
    
    	<span class="corners-bottom"><span></span></span></div>
    </div>
    
    
  • Open the file ./language/en/memberlist.php
  • Find this code:

    Code: Select all

    ));
    
  • Above it, add the following:

    Code: Select all

    	'LIKE_PROFILE_HEADER'	=> 'LIKED THREADS',
    
  • Add the following file ./styles/prosilver/template/likedlist_profile.html with the following content:

    Code: Select all

    <!-- IF S_DISPLAY_POST_INFO or PAGINATION or TOTAL_POSTS or TOTAL_TOPICS -->
    
        <!-- IF PAGINATION or TOTAL_POSTS or TOTAL_TOPICS -->
            <div class="pagination">
                <!-- IF not S_IS_BOT and U_MARK_TOPICS --><a href="{U_MARK_TOPICS}" accesskey="m">{L_MARK_TOPICS_READ}</a> &bull; <!-- ENDIF --><!-- IF TOTAL_TOPICS -->{TOTAL_TOPICS}<!-- ENDIF -->
                <!-- IF PAGE_NUMBER -->
                    <!-- IF PAGINATION --> &bull; <a href="#" onclick="jumpto(); return false;" title="{L_JUMP_TO_PAGE}">{PAGE_NUMBER}</a> &bull; <span>{PAGINATION}</span><!-- ELSE --> &bull; {PAGE_NUMBER}<!-- ENDIF -->
                <!-- ENDIF -->
            </div>
        <!-- ENDIF -->
    
    <!-- ENDIF -->
    <br />
    <!-- IF S_NO_READ_ACCESS -->
    
        <div class="panel">
            <div class="inner"><span class="corners-top"><span></span></span>
            <strong>{L_NO_READ_ACCESS}</strong>
            <span class="corners-bottom"><span></span></span></div>
        </div>
    
        <!-- IF not S_USER_LOGGED_IN -->
    
            <form action="{S_LOGIN_ACTION}" method="post">
    
            <div class="panel">
                <div class="inner"><span class="corners-top"><span></span></span>
    
                <div class="content">
                    <h3><a href="{U_LOGIN_LOGOUT}">{L_LOGIN_LOGOUT}</a>&nbsp; &bull; &nbsp;<a href="{U_REGISTER}">{L_REGISTER}</a></h3>
            
                    <fieldset class="fields1">
                    <dl>
                        <dt><label for="username">{L_USERNAME}:</label></dt>
                        <dd><input type="text" tabindex="1" name="username" id="username" size="25" value="{USERNAME}" class="inputbox autowidth" /></dd>
                    </dl>
                    <dl>
                        <dt><label for="password">{L_PASSWORD}:</label></dt>
                        <dd><input type="password" tabindex="2" id="password" name="password" size="25" class="inputbox autowidth" /></dd>
                        <!-- IF S_AUTOLOGIN_ENABLED --><dd><label for="autologin"><input type="checkbox" name="autologin" id="autologin" tabindex="3" /> {L_LOG_ME_IN}</label></dd><!-- ENDIF -->
                        <dd><label for="viewonline"><input type="checkbox" name="viewonline" id="viewonline" tabindex="4" /> {L_HIDE_ME}</label></dd>
                    </dl>
                    <dl>
                        <dt>&nbsp;</dt>
                        <dd><input type="submit" name="login" tabindex="5" value="{L_LOGIN}" class="button1" /></dd>
                    </dl>
                    </fieldset>
                </div>
    
                <span class="corners-bottom"><span></span></span></div>
            </div>
    
        <!-- ENDIF -->
    
    <!-- ENDIF -->
    
    <!-- BEGIN topicrow -->
        
        <!-- IF not topicrow.S_TOPIC_TYPE_SWITCH and not topicrow.S_FIRST_ROW -->
            </ul>
            <span class="corners-bottom"><span></span></span></div>
        </div>
        <!-- ENDIF -->
    
        <!-- IF topicrow.S_FIRST_ROW or not topicrow.S_TOPIC_TYPE_SWITCH -->
            <div class="forumbg<!-- IF topicrow.S_TOPIC_TYPE_SWITCH --> announcement<!-- ENDIF -->">
            <div class="inner"><span class="corners-top"><span></span></span>
            <ul class="topiclist">
                <li class="header">
                    <dl class="icon">
                        <dt><!-- IF S_DISPLAY_ACTIVE -->{L_ACTIVE_TOPICS}<!-- ELSEIF topicrow.S_TOPIC_TYPE_SWITCH and topicrow.S_TOPIC_TYPE gt 1 -->{L_ANNOUNCEMENTS}<!-- ELSE -->{L_TOPICS}<!-- ENDIF --></dt>
                        <dd class="likes">LIKES</dd>
                        <dd class="posts">{L_REPLIES}</dd>
                        <dd class="views">{L_VIEWS}</dd>
                        <dd class="lastpost"><span>{L_LAST_POST}</span></dd>
                    </dl>
                </li>
            </ul>
            <ul class="topiclist topics">
        <!-- ENDIF -->
        
            <li class="row<!-- IF topicrow.S_ROW_COUNT is even --> bg1<!-- ELSE --> bg2<!-- ENDIF --><!-- IF topicrow.S_POST_ANNOUNCE --> announce<!-- ENDIF --><!-- IF topicrow.S_POST_STICKY --> sticky<!-- ENDIF --><!-- IF topicrow.S_TOPIC_REPORTED --> reported<!-- ENDIF -->">
                <dl class="icon" style="background-image: url({topicrow.TOPIC_FOLDER_IMG_SRC}); background-repeat: no-repeat;">
                    <dt style="<!-- IF topicrow.TOPIC_ICON_IMG and S_TOPIC_ICONS -->background-image: url({T_ICONS_PATH}{topicrow.TOPIC_ICON_IMG}); background-repeat: no-repeat;<!-- ENDIF -->" title="{topicrow.TOPIC_FOLDER_IMG_ALT}"><!-- IF topicrow.S_UNREAD_TOPIC --><a href="{topicrow.U_NEWEST_POST}">{NEWEST_POST_IMG}</a> <!-- ENDIF --><a href="{topicrow.U_VIEW_TOPIC}" class="topictitle">{topicrow.TOPIC_TITLE}</a>
                        <!-- IF topicrow.S_TOPIC_UNAPPROVED or topicrow.S_POSTS_UNAPPROVED --><a href="{topicrow.U_MCP_QUEUE}">{topicrow.UNAPPROVED_IMG}</a> <!-- ENDIF -->
                        <!-- IF topicrow.S_TOPIC_REPORTED --><a href="{topicrow.U_MCP_REPORT}">{REPORTED_IMG}</a><!-- ENDIF --><br />
                        <!-- IF topicrow.PAGINATION --><strong class="pagination"><span>{topicrow.PAGINATION}</span></strong><!-- ENDIF -->
                        <!-- IF topicrow.ATTACH_ICON_IMG -->{topicrow.ATTACH_ICON_IMG} <!-- ENDIF -->{L_POST_BY_AUTHOR} {topicrow.TOPIC_AUTHOR_FULL} {L_POSTED_ON_DATE} {topicrow.FIRST_POST_TIME}<br />
                    </dt>
                    <dd class="likes">{topicrow.LIKE_COUNT} </dd>
                    <dd class="posts">{topicrow.REPLIES} <dfn>{L_REPLIES}</dfn></dd>
                    <dd class="views">{topicrow.VIEWS} <dfn>{L_VIEWS}</dfn></dd>
                    <dd class="lastpost"><span><dfn>{L_LAST_POST} </dfn>{L_POST_BY_AUTHOR} {topicrow.LAST_POST_AUTHOR_FULL}
                        <a href="{topicrow.U_LAST_POST}">{LAST_POST_IMG}</a> <br />{L_POSTED_ON_DATE} {topicrow.LAST_POST_TIME}</span>
                    </dd>
                </dl>
            </li>
    
        <!-- IF topicrow.S_LAST_ROW -->
                </ul>
            <span class="corners-bottom"><span></span></span></div>
        </div>
        <!-- ENDIF -->
    
    <!-- BEGINELSE -->
        <!-- IF S_IS_POSTABLE -->
        <div class="panel">
            <div class="inner"><span class="corners-top"><span></span></span>
            <strong>{L_NO_TOPICS}</strong>
            <span class="corners-bottom"><span></span></span></div>
        </div>
        <!-- ENDIF -->
    <!-- END topicrow -->
    
    <!-- IF S_SELECT_SORT_DAYS and not S_DISPLAY_ACTIVE -->
        <form method="post" action="{S_FORUM_ACTION}">
            <fieldset class="display-options">
                <!-- IF PREVIOUS_PAGE --><a href="{PREVIOUS_PAGE}" class="left-box {S_CONTENT_FLOW_BEGIN}">{L_PREVIOUS}</a><!-- ENDIF -->
                <!-- IF NEXT_PAGE --><a href="{NEXT_PAGE}" class="right-box {S_CONTENT_FLOW_END}">{L_NEXT}</a><!-- ENDIF -->
                <label>{L_DISPLAY_TOPICS}: {S_SELECT_SORT_DAYS}</label> 
                <label>{L_SORT_BY} {S_SELECT_SORT_KEY}</label> 
                <label>{S_SELECT_SORT_DIR} <input type="submit" name="sort" value="{L_GO}" class="button2" /></label>
            </fieldset>
        </form>
        <hr />
    <!-- ENDIF -->
    
    <!-- IF .topicrow and not S_DISPLAY_ACTIVE -->
        <div class="topic-actions">
            <!-- IF not S_IS_BOT and S_DISPLAY_POST_INFO -->
            <div class="buttons">
                <div class="<!-- IF S_IS_LOCKED -->locked-icon<!-- ELSE -->post-icon<!-- ENDIF -->"><a href="{U_POST_NEW_TOPIC}"><span><!-- IF S_IS_LOCKED -->{L_FORUM_LOCKED}<!-- ELSE -->{L_POST_TOPIC}<!-- ENDIF --></span></a></div>
            </div>
            <!-- ENDIF -->
        
            <!-- IF PAGINATION or TOTAL_POSTS or TOTAL_TOPICS -->
            <div class="pagination">
                <!-- IF TOTAL_TOPICS and not S_IS_BOT and U_MARK_TOPICS --><a href="{U_MARK_TOPICS}">{L_MARK_TOPICS_READ}</a> &bull;  <!-- ENDIF -->
                <!-- IF TOTAL_POSTS and not NEWEST_USER --> {TOTAL_POSTS}<!-- ELSEIF TOTAL_TOPICS and not NEWEST_USER --> {TOTAL_TOPICS}<!-- ENDIF -->
                <!-- IF TOTAL_USERS -->{TOTAL_USERS}<!-- ENDIF -->
                <!-- IF PAGINATION --> &bull;  <a href="#" onclick="jumpto(); return false;" title="{L_JUMP_TO_PAGE}">{PAGE_NUMBER}</a>
                 &bull;  <span>{PAGINATION}</span><!-- ELSE --> &bull; {PAGE_NUMBER}<!-- ENDIF -->
            </div>
            <!-- ENDIF -->
        </div>
    <!-- ENDIF -->
    
  • Open the file ./includes/functions_display
  • Find the following code:

    Code: Select all

    ?>
    
  • Before it, add the following code:

    Code: Select all

    function get_liked_list_profile($user_id, $start = 0, $end = false)
    {
        global $db, $config, $auth;
        
        $ex_fid_ary = array_keys($auth->acl_getf('!f_read', true));
        
        $sql = "SELECT A.topic_id,
                    (SELECT COUNT(topic_id) FROM phpbb_likes WHERE topic_id=A.topic_id) AS count,
                    B.forum_id,
                    B.topic_type,
                    B.topic_replies_real,
                    B.topic_replies,
                    B.topic_status,
                    B.topic_moved_id,
                    B.topic_last_post_time,
                    B.topic_approved,
                    B.topic_poster,
                    B.topic_first_poster_name,
                    B.topic_time,
                    B.topic_last_post_subject,
                    B.topic_last_post_time,
                    B.topic_last_poster_id,
                    B.topic_views,
                    B.topic_title,
                    B.icon_id,
                    B.topic_attachment,
                    B.topic_first_poster_name,
                    B.topic_last_post_id,
                    B.topic_last_poster_id,
                    B.topic_last_poster_name,
                    B.topic_last_poster_colour,
                    B.topic_last_post_subject,
                    B.topic_last_post_time,
                    B.topic_last_view_time
                FROM phpbb_likes as A, phpbb_topics AS B WHERE A.topic_id=B.topic_id AND user_id=$user_id ".            
                ((sizeof($ex_fid_ary)) ? ' AND ' . $db->sql_in_set('B.forum_id', $ex_fid_ary, true) : '') .
                "GROUP BY A.topic_id ORDER BY count DESC LIMIT 50;";
                
        /*if(!($result = $db->sql_query_limit($sql, $end, $start)))
        {
            message_die(GENERAL_ERROR, 'Error retrieving search results', '', __LINE__, __FILE__, $sql);
        }*/
        
        $result = $db->sql_query($sql);
        
        $result_set = $db->sql_fetchrowset($result);
    
        return $result_set;   
    }
    
  • Open the file ./memberlist.php
  • Find this code:

    Code: Select all

    	break;
    
    	case 'email':
    
  • Before it, add the following code:

    Code: Select all

            
            // Show list of liked threads 
            $start = request_var('start', 0);
            $result_set = get_liked_list_profile($user_id, $start);
    
            foreach ($result_set as $row)
                    {
                        $topic_id = $row['topic_id'];
                        $forum_id = $row['forum_id'];
    
                        // This will allow the style designer to output a different header
                        // or even separate the list of announcements from sticky and normal topics
                        $s_type_switch_test = ($row['topic_type'] == POST_ANNOUNCE || $row['topic_type'] == POST_GLOBAL) ? 1 : 0;
    
                        // Replies
                        $replies = ($auth->acl_get('m_approve', $forum_id)) ? $row['topic_replies_real'] : $row['topic_replies'];
    
                        if ($row['topic_status'] == ITEM_MOVED)
                        {
                            $topic_id = $row['topic_moved_id'];
                            $unread_topic = false;
                        }
                        else
                        {
                            $unread_topic = (isset($topic_tracking_info[$topic_id]) && $row['topic_last_post_time'] > $topic_tracking_info[$topic_id]) ? true : false;
                        }
    
                        // Get folder img, topic status/type related information
                        $folder_img = $folder_alt = $topic_type = '';
                        topic_status($row, $replies, $unread_topic, $folder_img, $folder_alt, $topic_type);
    
                        // Generate all the URIs ...
                        $view_topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . (($row['forum_id']) ? $row['forum_id'] : $forum_id) . '&t=' . $topic_id);
    
                        $topic_unapproved = (!$row['topic_approved'] && $auth->acl_get('m_approve', $forum_id)) ? true : false;
                        $posts_unapproved = ($row['topic_approved'] && $row['topic_replies'] < $row['topic_replies_real'] && $auth->acl_get('m_approve', $forum_id)) ? true : false;
                        $u_mcp_queue = ($topic_unapproved || $posts_unapproved) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&mode=' . (($topic_unapproved) ? 'approve_details' : 'unapproved_posts') . "&t=$topic_id", true, $user->session_id) : '';
    
    
    
                        $template->assign_block_vars('topicrow', array(
                            'FORUM_ID'                    => $forum_id,
                            'TOPIC_ID'                    => $topic_id,
                            'TOPIC_AUTHOR'                => get_username_string('username', $row['topic_poster'], $row['topic_first_poster_name']),
                            'TOPIC_AUTHOR_COLOUR'        => get_username_string('colour', $row['topic_poster'], $row['topic_first_poster_name']),
                            'TOPIC_AUTHOR_FULL'            => get_username_string('full', $row['topic_poster'], $row['topic_first_poster_name']),
                            'FIRST_POST_TIME'            => $user->format_date($row['topic_time']),
                            'LAST_POST_SUBJECT'            => censor_text($row['topic_last_post_subject']),
                            'LAST_POST_TIME'            => $user->format_date($row['topic_last_post_time']),
                            'LAST_VIEW_TIME'            => $user->format_date($row['topic_last_view_time']),
                            'LAST_POST_AUTHOR'            => get_username_string('username', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']),
                            'LAST_POST_AUTHOR_COLOUR'    => get_username_string('colour', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']),
                            'LAST_POST_AUTHOR_FULL'        => get_username_string('full', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']),
                            'LIKE_COUNT'                =>  $row['count'],
    
                            'PAGINATION'        => topic_generate_pagination($replies, $view_topic_url),
                            'REPLIES'            => $replies,
                            'VIEWS'                => $row['topic_views'],
                            'TOPIC_TITLE'        => censor_text($row['topic_title']),
                            'TOPIC_TYPE'        => $topic_type,
    
                            'TOPIC_FOLDER_IMG'        => $user->img($folder_img, $folder_alt),
                            'TOPIC_FOLDER_IMG_SRC'    => $user->img($folder_img, $folder_alt, false, '', 'src'),
                            'TOPIC_FOLDER_IMG_ALT'    => $user->lang[$folder_alt],
                            'TOPIC_ICON_IMG'        => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['img'] : '',
                            'TOPIC_ICON_IMG_WIDTH'    => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['width'] : '',
                            'TOPIC_ICON_IMG_HEIGHT'    => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['height'] : '',
                            'ATTACH_ICON_IMG'        => ($auth->acl_get('u_download') && $auth->acl_get('f_download', $forum_id) && $row['topic_attachment']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '',
                            'UNAPPROVED_IMG'        => ($topic_unapproved || $posts_unapproved) ? $user->img('icon_topic_unapproved', ($topic_unapproved) ? 'TOPIC_UNAPPROVED' : 'POSTS_UNAPPROVED') : '',
    
                            
    
                            'S_TOPIC_TYPE'            => $row['topic_type'],
                            'S_USER_POSTED'            => (isset($row['topic_posted']) && $row['topic_posted']) ? true : false,
                            'S_UNREAD_TOPIC'        => $unread_topic,
                            'S_TOPIC_REPORTED'        => (!empty($row['topic_reported']) && $auth->acl_get('m_report', $forum_id)) ? true : false,
                            'S_TOPIC_UNAPPROVED'    => $topic_unapproved,
                            'S_POSTS_UNAPPROVED'    => $posts_unapproved,
                            'S_HAS_POLL'            => (isset($row['poll_start']) && $row['poll_start'])  ? true : false,
                            'S_POST_ANNOUNCE'        => ($row['topic_type'] == POST_ANNOUNCE) ? true : false,
                            'S_POST_GLOBAL'            => ($row['topic_type'] == POST_GLOBAL) ? true : false,
                            'S_POST_STICKY'            => ($row['topic_type'] == POST_STICKY) ? true : false,
                            'S_TOPIC_LOCKED'        => ($row['topic_status'] == ITEM_LOCKED) ? true : false,
                            'S_TOPIC_MOVED'            => ($row['topic_status'] == ITEM_MOVED) ? true : false,
    
                            'U_NEWEST_POST'            => $view_topic_url . '&view=unread#unread',
                            'U_LAST_POST'            => $view_topic_url . '&p=' . $row['topic_last_post_id'] . '#p' . $row['topic_last_post_id'],
                            'U_LAST_POST_AUTHOR'    => get_username_string('profile', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']),
                            'U_TOPIC_AUTHOR'        => get_username_string('profile', $row['topic_poster'], $row['topic_first_poster_name']),
                            'U_VIEW_TOPIC'            => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $forum_id . '&t=' . $topic_id),
                            'U_MCP_REPORT'            => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports&mode=reports&f=' . $forum_id . '&t=' . $topic_id, true, $user->session_id),
                            'U_MCP_QUEUE'            => $u_mcp_queue,
                            'S_TOPIC_TYPE_SWITCH'    => ($s_type_switch == $s_type_switch_test) ? -1 : $s_type_switch_test)
                        );
    
                        $s_type_switch = ($row['topic_type'] == POST_ANNOUNCE || $row['topic_type'] == POST_GLOBAL) ? 1 : 0;
                    }
                    $template->assign_vars(array(
                        'PAGINATION'    => generate_pagination(append_sid("{$phpbb_root_path}likedlist.$phpEx"), $topics_count, $config['topics_per_page'], $start),
                        'PAGE_NUMBER'    => on_page($topics_count, $config['topics_per_page'], $start),
                        'TOTAL_TOPICS'    => (true) ? false : (($topics_count == 1) ? $user->lang['PTT_NUM_TOPIC'] : sprintf($user->lang['PTT_NUM_TOPICS'], $topics_count)),
                        'S_DISPLAY_SEARCHBOX'        => true,
                        )
                    );
                    $template->set_filenames(array(
                        'body' => 'likedlist_profile.html',
                    ));
                
                    // END Query to get list -----------------------------------------------------
    
    
Here is how the finished profile looks like:

Image

Again, it is not 100% done, but the core of it is done. Now I have to work on paging and some style issues, as well as supporting subsilver2 theme. :)

Pete
Last edited by digioz on Fri Jan 21, 2011 1:14 pm, edited 1 time in total.
DigiOz Multimedia
http://www.digioz.com

User avatar
keith10456
Registered User
Posts: 2315
Joined: Thu Feb 24, 2005 6:55 pm
Contact:

Re: [DEV] "Like" Mod

Post by keith10456 » Thu Jan 13, 2011 6:08 pm

Thanks for the update...

User avatar
shaw6096
Registered User
Posts: 4
Joined: Fri Jan 21, 2011 2:06 am
Location: Taiwan

Re: [DEV] "Like" Mod

Post by shaw6096 » Fri Jan 21, 2011 2:11 am

digioz wrote: Here is how the finished profile looks like:

Image

Again, it is not 100% done, but the core of it is done. Now I have to work on paging and some style issues, as well as supporting subsilver2 theme. :)

Pete
Thanks for your improve function become more perfect.
As my opinion, Could you change the Like column as "all user exist like value" instead of "this user like value" in this page?
I'm appreciate your contribution. Thank you very much.

User avatar
shaw6096
Registered User
Posts: 4
Joined: Fri Jan 21, 2011 2:06 am
Location: Taiwan

Re: [DEV] "Like" Mod

Post by shaw6096 » Fri Jan 21, 2011 2:19 am

Image

Thanks for your improve for this function.

I will appreciate that you can change the like column as "exist user like values" instead of "this user like value" in this page.

Thanks again for your contribution.

User avatar
digioz
Registered User
Posts: 297
Joined: Thu Feb 05, 2004 9:20 pm
Location: Chicago, IL
Name: DigiOz Multimedia
Contact:

Re: [DEV] "Like" Mod

Post by digioz » Fri Jan 21, 2011 4:32 am

shaw6096 wrote: Thanks for your improve for this function.

I will appreciate that you can change the like column as "exist user like values" instead of "this user like value" in this page.

Thanks again for your contribution.
The "Liked" column shows the total number of times "any" user has liked a specific thread. I hope this makes sense.

Pete
DigiOz Multimedia
http://www.digioz.com

User avatar
shaw6096
Registered User
Posts: 4
Joined: Fri Jan 21, 2011 2:06 am
Location: Taiwan

Re: [DEV] "Like" Mod

Post by shaw6096 » Fri Jan 21, 2011 7:04 am

digioz wrote:
shaw6096 wrote: Thanks for your improve for this function.

I will appreciate that you can change the like column as "exist user like values" instead of "this user like value" in this page.

Thanks again for your contribution.
The "Liked" column shows the total number of times "any" user has liked a specific thread. I hope this makes sense.

Pete

Code: Select all

FROM phpbb_likes as A, phpbb_topics AS B WHERE A.topic_id=B.topic_id AND user_id=$user_id ".            
            ((sizeof($ex_fid_ary)) ? ' AND ' . $db->sql_in_set('B.forum_id', $ex_fid_ary, true) : '') .
            "GROUP BY A.topic_id ORDER BY count DESC LIMIT 50;";
Per user only can click one like per topic. According to this rule, the sql WHERE A.topic_id=B.topic_id AND user_id=$user_id " will only show "1".
You can refer my attachment images.
Please check this again, thank you.
Image
image source

User avatar
digioz
Registered User
Posts: 297
Joined: Thu Feb 05, 2004 9:20 pm
Location: Chicago, IL
Name: DigiOz Multimedia
Contact:

Re: [DEV] "Like" Mod

Post by digioz » Fri Jan 21, 2011 1:01 pm

shaw6096 wrote:Per user only can click one like per topic. According to this rule, the sql WHERE A.topic_id=B.topic_id AND user_id=$user_id " will only show "1".
You can refer my attachment images.
Please check this again, thank you.
Ah, I see where the problem is now. Here is the correction. The query should read:

Code: Select all

SELECT A.topic_id,
                (SELECT COUNT(topic_id) FROM phpbb_likes WHERE topic_id=A.topic_id) AS count,
                B.forum_id,
                B.topic_type,
                B.topic_replies_real,
                B.topic_replies,
                B.topic_status,
                B.topic_moved_id,
                B.topic_last_post_time,
                B.topic_approved,
                B.topic_poster,
                B.topic_first_poster_name,
                B.topic_time,
                B.topic_last_post_subject,
                B.topic_last_post_time,
                B.topic_last_poster_id,
                B.topic_views,
                B.topic_title,
                B.icon_id,
                B.topic_attachment,
                B.topic_first_poster_name,
                B.topic_last_post_id,
                B.topic_last_poster_id,
                B.topic_last_poster_name,
                B.topic_last_poster_colour,
                B.topic_last_post_subject,
                B.topic_last_post_time,
                B.topic_last_view_time
            FROM phpbb_likes as A, phpbb_topics AS B WHERE A.topic_id=B.topic_id AND user_id=$user_id ".            
            ((sizeof($ex_fid_ary)) ? ' AND ' . $db->sql_in_set('B.forum_id', $ex_fid_ary, true) : '') .
            "GROUP BY A.topic_id ORDER BY count DESC LIMIT 50;";
As much as I am not a fan of Sub-Select statements, in this case it seems to be unavoidable. :lol:

Pete
DigiOz Multimedia
http://www.digioz.com

User avatar
shaw6096
Registered User
Posts: 4
Joined: Fri Jan 21, 2011 2:06 am
Location: Taiwan

Re: [DEV] "Like" Mod

Post by shaw6096 » Sat Jan 22, 2011 8:49 am

digioz wrote: Ah, I see where the problem is now. Here is the correction. The query should read:

As much as I am not a fan of Sub-Select statements, in this case it seems to be unavoidable. :lol:

Pete
Great! I'm very appreciation your effort to make the function more and more well.
:lol:

User avatar
digioz
Registered User
Posts: 297
Joined: Thu Feb 05, 2004 9:20 pm
Location: Chicago, IL
Name: DigiOz Multimedia
Contact:

Re: [DEV] "Like" Mod

Post by digioz » Tue Jan 25, 2011 2:16 am

shaw6096 wrote:Great! I'm very appreciation your effort to make the function more and more well.
:lol:
You are very welcome. It looks like this Mod is getting closer and closer to completion. The only major issue I have left is the paging of the two lists.
DigiOz Multimedia
http://www.digioz.com

danmcq
Registered User
Posts: 3
Joined: Tue Jan 25, 2011 12:35 am

Re: [DEV] "Like" Mod

Post by danmcq » Tue Jan 25, 2011 2:21 am

Hello, is it possible to add a 'Likes' column to the main forums display so that the total number of likes for each topic is displayed?

User avatar
digioz
Registered User
Posts: 297
Joined: Thu Feb 05, 2004 9:20 pm
Location: Chicago, IL
Name: DigiOz Multimedia
Contact:

Re: [DEV] "Like" Mod

Post by digioz » Tue Jan 25, 2011 4:59 am

Of course anything is possible when you are custom coding, but I am not sure it would be desired by all forum users, so for our first release it will not be included. Perhaps for future releases we can add a setting that enables forum admin to turn this on/off.
DigiOz Multimedia
http://www.digioz.com

danmcq
Registered User
Posts: 3
Joined: Tue Jan 25, 2011 12:35 am

Re: [DEV] "Like" Mod

Post by danmcq » Tue Jan 25, 2011 6:11 am

Here is why I was wondering.. I am helping a friend with a new site focused around user submitted designs (images) and one of the features we would like to be central is which submissions are being 'liked' the most. I love the 'most liked page,' could you possibly point me in the direction to code that functionality into the main forum? I'm relatively new to phpbb but I catch on quick ;) no worries if you think it would be too difficult. Thanks for an awesome mod, great job.

User avatar
digioz
Registered User
Posts: 297
Joined: Thu Feb 05, 2004 9:20 pm
Location: Chicago, IL
Name: DigiOz Multimedia
Contact:

Re: [DEV] "Like" Mod

Post by digioz » Tue Jan 25, 2011 8:23 pm

Hey Dan,

Sorry for the late response. Here is an approximate game plan of the files you will need to modify:
  • ./styles/prosilver/template/viewforum_body.html - Add new "Liked" column
  • ./viewforum.php - around line 645 find the source of query and add a join to phpbb_likes table
  • ./viewforum.php - around line 681 add the "Liked" column info inside the foreach loop
Again, sorry I can't give you more exact details, but unfortunately I have had a very busy few days. If you get stuck let me know and I will try to help you more.

Thanks,
Pete
DigiOz Multimedia
http://www.digioz.com

Locked

Return to “[3.0.x] Abandoned MODs”