Login  |  Register
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome, Guest. Please login or register.
Did you miss your activation email?

August 12, 2022, 05:47:20 PM

Login with username, password and session length
Members
  • Total Members: 3842
  • Latest: Kokoro
Stats
  • Total Posts: 193479
  • Total Topics: 21088
  • Online today: 50
  • Online ever: 1035
  • (November 26, 2020, 04:45:12 AM)
Users Online
Users: 1
Guests: 38
Total: 39

Author Topic: help to change the "normal" block "recent topics"  (Read 2076 times)

0 Members and 1 Guest are viewing this topic.

Offline dan4ever

  • Jr. Member
  • **
  • Posts: 7
help to change the "normal" block "recent topics"
« on: June 22, 2021, 08:40:22 AM »
hi

Where can I change the built in block "recent topics".
I want the user how posted not bold text and the topic bold instead.
And if you klick on the avatar I will come to the post, not the profil!!!!!

And maybe lite text from the post too if its possible.

/Dan

Offline @rjen

  • Support Team
  • *
  • Posts: 3285
    • FJR-club Nederland
Re: help to change the "normal" block "recent topics"
« Reply #1 on: June 23, 2021, 01:18:05 PM »
If you want to change the layout of the standard recent topics you will have to edit this file: TPsubs.template.php

Look for the section that starts with:
// blocktype 12: Recent Topics
Running Latest TP on SMF2.1 at: www.fjr-club.nl

Testing TP on SMF2.0
Testing TP on SMF2.1 (latest Github)
Want to check what php version I am testing on? See: PHP Info

Offline dan4ever

  • Jr. Member
  • **
  • Posts: 7
Re: help to change the "normal" block "recent topics"
« Reply #2 on: June 25, 2021, 07:01:08 AM »
or maybe ask if I can use an "php-box" I used with my last portal?
But it's not working just like that, somebody have to look into the code and fix a little, I think.
I post it here and say what u think:

Code: [Select]
<?php

/* Recent posts with post preview */

/* SETUP */

$topics_posts 1; // TOPICS - 1 | MESSAGES - 2
$limit 25; // How many recent posts do you want to output?
$number 90; // How many characters do you want to output?
$exclude_boards = array( 444586); // IF null guests can see all boards | IF you want to hide some boards use: array( ID1, ID2, ID3) where ID is the board's ID
$htmlspecialcharacters true// Do you need to show html special characters like Greek characters?

// Scroll Enable? Height and Speed?
$scrolling =0;       // ENABLE - 1 | DISABLE - 2
$speed 3;           // SLOW - 1 | MEDIUM - 10 | FAST - 20
$height "350px";
$scrollbar 0;       // ENABLE - 1 | DISABLE - 2

// Do you want to translate it to your own language? :P
$text['board'] = 'i';
$text['who'] = 'av';

/* [STOP!] - THIS IS THE END OF SETUP */

//Only code from now on ;)
global $smcFunc$scripturl$sourcedir$modSettings$user_info$settings$context;


// Let's grab some database results
if ($topics_posts == 1) {

if (is_array($exclude_boards) || (int) $exclude_boards === $exclude_boards)
{
$exclude_boards is_array($exclude_boards) ? $exclude_boards : array($exclude_boards);
}
elseif ($exclude_boards != null)
{
$output_method $exclude_boards;
$exclude_boards = array();
}

$posts_result $smcFunc['db_query']('''
   SELECT m.poster_name, m.poster_time, m.id_msg, t.id_member_updated, m.subject, m.body, m.id_topic, b.name, t.id_last_msg, u.avatar, g.online_color,' 
. ($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'
) . '
   FROM {db_prefix}topics AS t
   LEFT JOIN {db_prefix}boards AS b ON (t.id_board = b.id_board)
   LEFT JOIN {db_prefix}messages AS m ON (m.id_msg = t.id_last_msg)
   LEFT JOIN {db_prefix}members AS u ON (t.id_member_updated = u.id_member)
   LEFT JOIN {db_prefix}membergroups AS g ON (g.id_group = CASE WHEN u.id_group = 0 THEN u.id_post_group ELSE u.id_group END)
   ' 
. (!$user_info['is_guest'] ? '
LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = m.id_topic AND lt.id_member = ' 
$user_info['id'] . ')
LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = ' 
$user_info['id'] . ')' '') . '     
   WHERE m.approved=1'   
. (empty($exclude_boards) ? '' '
AND b.id_board NOT IN ({array_int:exclude_boards})'
) . ' AND {query_see_board}
   ORDER BY t.id_last_msg DESC
   LIMIT ' 
$limit
array(
'exclude_boards' => empty($exclude_boards) ? '' $exclude_boards,
)   
   );
$posts = array();
while (
$row_posts $smcFunc['db_fetch_assoc']($posts_result))
{

      global 
$memberContext;
      
loadMemberData($row_posts['id_member_updated']);
      
loadMemberContext($row_posts['id_member_updated']);

   
$posts[] = array(
  'id' => $row_posts['id_member_updated'],
      
'username' => '<a style="color: ' $row_posts['online_color'] . ';" href="' $scripturl '?action=profile;u=' $row_posts['id_member_updated'] . '">' $row_posts['poster_name'] . '</a>',
      
'subject' => '<a style="font-weight: bold;" title="' $text['board'] . ' ' $row_posts['name'] .'" href="' $scripturl '?topic=' $row_posts['id_topic'] . '.msg' $row_posts['id_last_msg'] . ';topicseen#new">' $row_posts['subject'] . '</a>',
      
'body' => $row_posts['body'],
  'avatar' => $row_posts['avatar'] == '' $memberContext[$row_posts['id_member_updated']]['avatar']['href'] : (stristr($row_posts['avatar'], 'https://') ? $row_posts['avatar'] : $modSettings['avatar_url'] . '/' $row_posts['avatar']),
  'board' => $row_posts['name'], 
  'time' => timeformat($row_posts['poster_time']),
  'new' => !empty($row_posts['is_read'])
   );
}
$smcFunc['db_free_result']($posts_result);

} else {

if (is_array($exclude_boards) || (int) $exclude_boards === $exclude_boards)
{
$exclude_boards is_array($exclude_boards) ? $exclude_boards : array($exclude_boards);
}
elseif ($exclude_boards != null)
{
$output_method $exclude_boards;
$exclude_boards = array();
}

$posts_result $smcFunc['db_query']('''
   SELECT m.poster_name, m.poster_time, m.id_msg, m.id_member, m.subject, m.body, m.id_topic, b.name, b.id_board, u.avatar, g.online_color,' 
. ($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'
) . '
   FROM {db_prefix}messages AS m
   LEFT JOIN {db_prefix}boards AS b ON (m.id_board = b.id_board)
   LEFT JOIN {db_prefix}members AS u ON (m.id_member = u.id_member)
   LEFT JOIN {db_prefix}membergroups AS g ON (g.id_group = CASE WHEN u.id_group = 0 THEN u.id_post_group ELSE u.id_group END)
   ' 
. (!$user_info['is_guest'] ? '
LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = m.id_topic AND lt.id_member = ' 
$user_info['id'] . ')
LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = ' 
$user_info['id'] . ')' '') . '   
   WHERE m.approved=1'   
. (empty($exclude_boards) ? '' '
AND b.id_board NOT IN ({array_int:exclude_boards})'
) . ' AND {query_see_board}
   ORDER BY m.id_msg DESC
   LIMIT ' 
$limit
array(
'exclude_boards' => empty($exclude_boards) ? '' $exclude_boards,
)   
   );
$posts = array();
while (
$row_posts $smcFunc['db_fetch_assoc']($posts_result))
{

      global 
$memberContext;
      
loadMemberData($row_posts['id_member']);
      
loadMemberContext($row_posts['id_member']);

   
$posts[] = array(
  'id' => $row_posts['id_member'],
      
'username' => '<a style="color: ' $row_posts['online_color'] . ';" href="' $scripturl '?action=profile;u=' $row_posts['id_member'] . '">' $row_posts['poster_name'] . '</a>',
      
'subject' => '<a style="font-weight: bold;" title="' $text['board'] . ' ' $row_posts['name'] .'" href="' $scripturl '?topic=' $row_posts['id_topic'] . '.msg' $row_posts['id_msg'] . ';topicseen#new">' $row_posts['subject'] . '</a>',
      
'body' => $row_posts['body'],
  'avatar' => $row_posts['avatar'] == '' $memberContext[$row_posts['id_member']]['avatar']['href'] : (stristr($row_posts['avatar'], 'https://') ? $row_posts['avatar'] : $modSettings['avatar_url'] . '/' $row_posts['avatar']),
  'board' => $row_posts['name'],  
  'time' => timeformat($row_posts['poster_time']),
  'new' => !empty($row_posts['is_read'])
   );
}
$smcFunc['db_free_result']($posts_result);

}

//Finally the Output

//Scrolling xD
if ($scrolling == 1)
echo 
'<div style="overflow: hidden;"><marquee height=' $height ' behavior="scroll" direction="up" scrollamount="' $speed '" onmouseover="this.stop()" onmouseout="this.start()">';

if (
$scrollbar == 1)
echo 
'<div style="height:' $height '; overflow-y: scroll; overflow-x: hidden;">';

foreach (
$posts as $post) {

// Lets fix the BBCode bug and Strip the Text
$content1 str_replace("[""<"$post['body']);
$content2 str_replace("]"">"$content1); 
$content3 strip_tags($content2);
$preview substr ($content3,0,$number);

echo
'<table>
<tr>
<td style="width: 40px;">
<img src="' 
$post['avatar'] .'" alt="" width="40px" height="40px" />
</td>
<td>
$post['subject'];

if (!$post['new'] && $context['user']['is_logged'])
echo ' <img src="'$settings['images_url'], '/'$context['user']['language'], '/new.gif" alt="new" border="0" />';

echo '<br />
<small>' 
$text['who'] . ' ' $post['username'] . ' | ' $post['time'] .'</small>
</td>
</tr>
</table>'
;

if ($htmlspecialcharacters) {
echo htmlspecialchars($previewENT_NOQUOTES"UTF-8") . '...';
} else {
echo $preview '...';
}

echo 
'<hr />';
}
        
//Scrolling xD
if ($scrollbar == 1)
echo 
'</div>'

if (
$scrolling == 1)
echo 
'</marquee></div>';

?>

Offline @rjen

  • Support Team
  • *
  • Posts: 3285
    • FJR-club Nederland
Re: help to change the "normal" block "recent topics"
« Reply #3 on: June 25, 2021, 07:44:53 AM »
Of course, a php block can be used , but that’s not what you asked for…
Running Latest TP on SMF2.1 at: www.fjr-club.nl

Testing TP on SMF2.0
Testing TP on SMF2.1 (latest Github)
Want to check what php version I am testing on? See: PHP Info

Offline dan4ever

  • Jr. Member
  • **
  • Posts: 7
Re: help to change the "normal" block "recent topics"
« Reply #4 on: June 25, 2021, 10:45:20 AM »
Of course, a php block can be used , but that’s not what you asked for…
No, you're so right
I started by asking for a "Facebook-flow", and now this...
I'm never satisfied until perfection  O0

And later on maybe some mod to the "Recent posts"

/Dan

Online tino

  • Developer
  • *
  • Posts: 2613
Re: help to change the "normal" block "recent topics"
« Reply #5 on: June 26, 2021, 06:49:10 AM »
What’s not working with the php block you posted? It should work as before as it’s not using any custom calls from a portal by what I can see.

Offline lurkalot

  • Administrator
  • *
  • Posts: 7409
    • Camera Craniums
Re: help to change the "normal" block "recent topics"
« Reply #6 on: June 26, 2021, 06:57:32 AM »
What’s not working with the php block you posted? It should work as before as it’s not using any custom calls from a portal by what I can see.

Works for me. Although you will have to remove the php tags from the start and end of the code for it to work.

Code: [Select]
<?php
and

Code: [Select]
?>

Offline dan4ever

  • Jr. Member
  • **
  • Posts: 7
Re: help to change the "normal" block "recent topics"
« Reply #7 on: June 26, 2021, 11:34:30 AM »
So simple, Thanks a lot!!!!

The member with no profil Picture(avatar) have a broken picture. (if u understand me?)
aren't there a "default"-avatar ??

/Dan
« Last Edit: June 28, 2021, 02:42:44 PM by dan4ever »

Online tino

  • Developer
  • *
  • Posts: 2613
Re: help to change the "normal" block "recent topics"
« Reply #8 on: June 28, 2021, 12:47:20 PM »
The &quote is an entity decoding issue. Does it do it using the built in TinyPortal Recent posts? If it doesn’t then you’ll have to look at what that’s doing for the entities.

The missing avatar will be the link, you probably have errors in the logs? If so you need to check they exist first if not go to the default one.

Offline dan4ever

  • Jr. Member
  • **
  • Posts: 7
Re: help to change the "normal" block "recent topics"
« Reply #9 on: July 05, 2021, 09:33:26 AM »
The missing avatar will be the link, you probably have errors in the logs? If so you need to check they exist first if not go to the default one.
No error in logs. 
But found this in "java-consul":
<img src="" alt="" width="40px" height="40px">

But if I go into the forum and look at the same member, java-consul says:
<span class="no_avatar Nybörjare">G</span>
And "Nybörjare" are a group a made like "newbie"

But does SMF have a default pic for a member?
$modSettings['avatar_url'] is empty
/Dan