To use this website completely, it is necessary to store cookies on your computer.
 

* Statistic

  • *Total Posts: 16418
  • *Total Topics: 2549
  • *Online Today: 8
  • *Most Online: 292
(2016 November 12, 09:37:31)
  • *Users: 0
  • *Guests: 0
  • *Spiders: 2
  • *Total: 2

  • *Yahoo!
  • *Baidu

Add new gif to topic where there is unread post(s)

Started by neverhurry, 2011 April 26, 13:33:55

previous topic - next topic

0 Members and 0 Guests are viewing this topic.

neverhurry

2011 April 26, 13:33:55
Hi, since I created inside Portamx a Mulltiple boardnews block, I would like to add a new gif to topic (title) where there is unread post(s). My php knowledge is poor but I grabbed something from SMF codes and here is my thinking how to approad this, I hope I can be advised by any of you, thanks.

1. open .../Source/Portamx/boardnewsmult.php
2. in line 84 add:
Code Select
IFNULL(mem.real_name, m.poster_name) AS poster_name, ' . ($user_info['is_guest'] ? '1 AS is_read, 0 AS new_from' : '
        IFNULL(lt.id_msg, IFNULL(lmr.id_msg, 0)) >= m.id_msg_modified AS is_read,
        IFNULL(lt.id_msg, IFNULL(lmr.id_msg, -1)) + 1 AS new_from') . ', SUBSTRING(m.body, 1, 384) AS body, m.smileys_enabled, m.icon


3. find
Code Select
WHERE b.id_board IN ({array_int:boards}) AND {query_wanna_see_board}'.

and add before it:

Code Select
LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member)' . (!$user_info['is_guest'] ? '
LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = t.id_topic AND lt.id_member = {int:current_member})
LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = {int:current_member})' : '') . '


4. find
Code Select
'views' => $row['num_views'],

and add after:

Code Select
'new' => !empty($row['is_read']),
            'is_new' => empty($row['is_read']),
'new_from' => $row['new_from'],


5. find

Code Select
<h4 id="pmx'.$this->cfg['id'].'bnmpos'. $post['message_id'] .'" class="'. $this->cfg['config']['visuals']['postheader'] .' catbg_grid">
'. $post['icon'] .'<span class="normaltext cat_msg_title"><a href="' . $scripturl . '?topic=' . $post['id'] . '.0">'. $post['subject'] .'</a></span>
</h4>


and change it to

Code Select
<h4 id="pmx'.$this->cfg['id'].'bnmpos'. $post['message_id'] .'" class="'. $this->cfg['config']['visuals']['postheader'] .' catbg_grid">
'. $post['icon'] .'<span class="normaltext cat_msg_title"><a href="' . $scripturl . '?topic=' . $post['id'] . '.0">'. $post['subject'] .'</a>', !$post['is_new'] ? '' : '<a href="' . $scripturl . '?topic=' . $post['topic'] . '.msg' . $post['new_from'] . ';topicseen#new" rel="nofollow"><img src="' . $settings['lang_images_url'] . '/new.gif" alt="' . $txt['new'] . '" border="0" /></a>', '</span>

</h4>



I thought it should work, cause they look logical to me, but unfortunately it doesn't work, it got an error says that there is no current_member data in the database.

Thank you very much to comment and advise!




feline

#1
2011 April 26, 21:26:02
if you add a variable in the query, so you have that also insert in the vars array ...
Many are stubborn in relation to the path, a few in relation to the target.

neverhurry

#2
2011 April 27, 15:57:34
Quote from: feline ,  2011 April 26, 21:26:02
if you add a variable in the query, so you have that also insert in the vars array ...


Fel, thanks. Do you mean the vars 'is_read' and 'new_from'? Which I do insert in the array ...

Code Select
'new' => !empty($row['is_read']),
'is_new' => empty($row['is_read']),
'new_from' => $row['new_from'],


I grabbed these codes from SMF's subs_recent.php (which is before SMF 2.0 RC3), but the comment there says that these code "// Retained for compatibility - is technically incorrect!", so probably here was the problem that the modification doesn't work. Is it so?

feline

#3
2011 April 27, 18:16:57
I mean this: {int:current_member}
for this you have to add the value in the query var array:
Code Select

array(
'boards' => $boards,
'is_approved' => 1
)


change that to:
Code Select
array(
'boards' => $boards,
'is_approved' => 1,
'current_member' => $user_info['id'],
)
Many are stubborn in relation to the path, a few in relation to the target.

neverhurry

#4
2011 May 15, 10:10:08
Quote from: feline ,  2011 April 27, 18:16:57
I mean this: {int:current_member}
for this you have to add the value in the query var array:
Code Select

array(
'boards' => $boards,
'is_approved' => 1
)


change that to:
Code Select
array(
'boards' => $boards,
'is_approved' => 1,
'current_member' => $user_info['id'],
)



Thanks, that did the trick. I added 'current_member' => $user_info['id'], to the code and that works.
I hope Portamx can add this small but useful function to next release. Have a nice Sunday!