1 (edited by Amelotti 2010-02-25 18:00)

Topic: Number-of-views in the show-my-topics feature (experience needed!)

When show-my-topics feature is posted via the search.php, it should show something like this

Replies |  Views |  Last post

23           34         09-Feb-2010 04:03 by Amelotti

But it doesn't show Views.

In order to insert the number-of-views, we steal the following expression from the viewforum.php, where it knows how to show it

            if ($forum_config['o_topic_views'] == '1')
                $forum_page['item_body']['info']['views'] = '<li class="info-views"><strong>'.forum_number_format($cur_topic['num_views']).'</strong> <span class="label">'.(($cur_topic['num_views'] == 1) ? $lang_forum['view'] : $lang_forum['views']).'</span></li>';

then change $cur_topic to $cur_set (by analogy) and put into the correspondent part of search.php between "replies" and "last post" (371-372)

However, it ain't workin' and shows only zeros, instead of the exact count, probably because $cur_set['num_views'] points in the wrong direction. (Neither does it work if we leave $cur_topic).

How can this be fixed?

Re: Number-of-views in the show-my-topics feature (experience needed!)

Could you please place blocks of php code in the tag "code"?
The count of topic views is not selected from the database. To select it, you need to edit the line 539 of the <FORUM_ROOT>/include/search_functions.php file:

'SELECT'    => 't.id AS tid, t.poster, t.subject, t.first_post_id, t.posted, t.last_post, t.last_post_id, t.last_poster, t.num_replies, t.closed, t.sticky, t.forum_id, f.forum_name, t.num_views',

In your code posted above you need to use the $cur_set variable. Also, don't forget to add the "Views" column to table's header.

3 (edited by Amelotti 2010-02-27 11:58)

Re: Number-of-views in the show-my-topics feature (experience needed!)

Well, well, well, not quite. It didn't seem to work when I inserted that code JUST in that place. But when I dumbly copied t.num_views NEAR t.num_replies THROUGHOUT the search-functions.php (over 7 times) inside the "$query = array(    )", it finally came out!


As to the header (search.php 173- ), in case someone uses the info in this thread, it should look as follows (one may have to correct lang/../forum.php too, if necessary), but that's easy:

        $forum_page['item_header']['subject']['title'] = '<strong class="subject-title">'.$lang_forum['Topics'].'</strong>';
    $forum_page['item_header']['info']['replies'] = '<strong class="info-replies-search">'.$lang_forum['Replies'].'</strong>';
    $forum_page['item_header']['info']['views'] = '<strong class="info-views-search">'.$lang_forum['Views'].'</strong>';
        $forum_page['item_header']['info']['lastpost'] = '<strong class="info-lastpost-search">'.$lang_forum['Last post'].'</strong>'; 

Could you please place blocks of php code in the tag "code"?

It normally shows as a long string in a frame that's hard to view or copy.