collapse

* Simple Portal Archived Forum

This is an Archive Forum.

The content in this forum may be out-of-date or have been superseded by newer information, and links in forum pages to other sites may not work.
This forum contains archives for future reference.

Visit our thread at Simple Machines Forum for current support.

SMF 2.1 users: EhPortal is a ported version of Simple Portal specifically designed for the SMF 2.1 branch.
Please visit web-develop.ca to download EhPortal and for its support.

* User Info

 
 
Welcome, Guest. Please login or register.

* Who's Online

  • Dot Guests: 379
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.

* Shoutbox

Refresh History
  • Shoutbox is not for support!
  • {OCS}MasterSeal: Yup, Still adore SP
    April 21, 2019, 07:08:06 PM
  • {OCS}MasterSeal: STILL love SP :)
    November 24, 2018, 05:05:50 AM
  • ♦ Ninja ZX-10RR ♦: <3 aegersz
    September 13, 2018, 03:36:09 PM
  • aegersz: I STILL <3 LOVE SimplePortal
    September 13, 2018, 07:11:39 AM
  • aegersz: o LOVE you guys - Simple Portal rocks !
    May 09, 2018, 05:18:59 AM
  • Chen Zhen: our apologies for the site being down.. please read server issues topic
    March 22, 2018, 05:32:38 AM
  • {OCS}MasterSeal: LOL PLEASE forget I just posted that. I found the answer in my own dang post back in 2015. lol sorry!
    July 04, 2017, 10:47:55 PM
  • {OCS}MasterSeal: I know this SB isnt' for support, but I just have a general question. Who would I contact to find out where SP stores its block info? Is it DB driven or files? I searched the site but came up with nothing. probably my fault any insight is appreciated.
    July 04, 2017, 10:43:36 PM
  • ♦ Ninja ZX-10RR ♦: Excuse me but what does Simpleportal have to deal with that?
    February 05, 2017, 08:21:14 PM
  • WhiteEagle: of course IMHO that site appears to be dead :(
    February 04, 2017, 01:08:05 PM
  • WhiteEagle: If I can get that, then I'll use it for that site...
    February 04, 2017, 01:07:35 PM
  • WhiteEagle: decided to not use SMF for any projects, unless I can get a copy of the premium version of the fanfiction archive plugin
    February 04, 2017, 01:06:54 PM
  • expertdecisions: cloudflare
    January 28, 2017, 08:01:47 AM
  • aegersz: SM release 2.0.13 !
    January 12, 2017, 06:00:13 AM
  • raffo: Tks Emanuele, even if I didn't understand the fix :D
    November 07, 2016, 02:01:20 AM
  • emanuele: [link]
    November 01, 2016, 12:43:50 PM
  • emanuele: raffo: the English support board is a good place. ;)
    November 01, 2016, 12:43:38 PM
  • raffo: Where can I find the fix for the shoutbox?
    November 01, 2016, 05:06:09 AM
  • {OCS}MasterSeal: To the SP team, I make a point to come here and thank you as much as possible for your work.  so again, THANK YOU!
    October 28, 2016, 10:38:05 AM
  • emanuele: That's indeed funny, the limit is present only in the patch and not the full install.
    October 22, 2016, 06:14:58 PM

* Recent Posts

Adding Forums Button to Nav bar by jirapon
[August 01, 2019, 09:07:12 AM]


Re: Board Icons by ♦ Ninja ZX-10RR ♦
[July 30, 2019, 04:03:41 PM]


MOVED: Czech translation???? by ♦ Ninja ZX-10RR ♦
[July 30, 2019, 03:04:51 PM]


Board Icons by jirapon
[July 30, 2019, 07:28:44 AM]


Re: Thankyou Simpleportal, by ♦ Ninja ZX-10RR ♦
[July 29, 2019, 09:41:29 AM]

Thanks for having an interest with our portal. If you have any requests for features, have a look at the Feature Requests board.

Author Topic: [Block] Recent Topics/Posts with Post Preview!  (Read 176501 times)

0 Members and 2 Guests are viewing this topic.

Offline AngelinaBelle

  • Comrade
  • *
  • Posts: 4870
  • Gender: Female
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: [Block] Recent Topics/Posts with Post Preview!
« Reply #160 on: February 27, 2014, 07:20:45 PM »
Sure.  that code is part of sp_userInfo though, not part of sp_recent
Every block is like a mini-page of your forum -- each one has to fetch info from your database.
You can cut down on the database work by cutting down on the number of blocks on your portal.
Please to keep this website running, if you like SimplePortal, make a
one-time subscription. Thank you for your support.

Have you tried the SimplePortal documentation?

Offline Tarista

  • Semi Newbie
  • *
  • Posts: 37
  • SMF Version: 2.0.10
  • SP Version: 2.3.5
Re: [Block] Recent Topics/Posts with Post Preview!
« Reply #161 on: February 28, 2014, 06:16:58 AM »
It was part of the custom block-code in the first page, perhaps to grab the avatar or something like that. I excluded it and the avatar as well and that made it load with fewer queries. :)
But while we're on the subject: Does active blocks load in the background even though it doesn't have to load on the page itself? It seems it might at least do that on SP Pages?

Offline AngelinaBelle

  • Comrade
  • *
  • Posts: 4870
  • Gender: Female
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: [Block] Recent Topics/Posts with Post Preview!
« Reply #162 on: February 28, 2014, 08:11:59 AM »
Every time you load a page, all the work has to be done to load that page.

So, for every block you see on a page, you can look through PortalBlocks.php and through your custom  php code to see exactly which queries are preparing your block.

Only blocks that show on the page have to be run when the page is loaded. Running code for blocks that do not need to be displayed would not make sense.
Of course, whenever SimplePortal is running, it always has to do a query to figure out which blocks are supposed to be displayed on the page.  As the blocks table is typically very much smaller than the messages table, searching for all blocks active on a given page probably means a LOT less work for the database than some searches through the messages table.
Please to keep this website running, if you like SimplePortal, make a
one-time subscription. Thank you for your support.

Have you tried the SimplePortal documentation?

Offline Tarista

  • Semi Newbie
  • *
  • Posts: 37
  • SMF Version: 2.0.10
  • SP Version: 2.3.5
Re: [Block] Recent Topics/Posts with Post Preview!
« Reply #163 on: February 28, 2014, 08:20:08 AM »
Makes sense :) Thank you for explaining. I guess I have not really learned how to read and completely understand the queries and php just yet.
So then I assume a page with 50 database queries could load faster than one with 27,  depending on the queries?
I've been trying to remove as many queries as I can to load the pages faster, also looking at the page created-time. But I guess I have to look at the code in the queries as well then.

Offline AngelinaBelle

  • Comrade
  • *
  • Posts: 4870
  • Gender: Female
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: [Block] Recent Topics/Posts with Post Preview!
« Reply #164 on: March 02, 2014, 06:04:23 PM »
You are correct -- it does depend on how complicated the query is, and on how large a table the query has to search, and how much of the table has to search, and on whether it has to search on things that are indexed or not.

There is a certain amount of overhead to any search, so I would be surprised if an "ordinary" page with 50 queries ran faster than one with 27, but you never know....

If you have a TON of messages, then searching the messages table could take a long time (one reason the recent_posts and recent_topics routines limit searches to only the most recent so many messages).  So a full-text search of the entire forum could take a VERY long time.  But a search of the modsettings table could be pretty quick.

How long some queries take can also depend on how your MySQL server is set up -- what it is optimizing and what it is not optimizing, and you probably don't have much control over that.  So many variables.  Indeed, you will have to experiment with turning blocks on and off to see what happens.
Please to keep this website running, if you like SimplePortal, make a
one-time subscription. Thank you for your support.

Have you tried the SimplePortal documentation?

Offline Rik

  • Newbie
  • Posts: 3
  • SMF Version: 2.0.7
  • SP Version: 2.3.5
Re: [Block] Recent Topics/Posts with Post Preview!
« Reply #165 on: May 04, 2014, 08:17:49 AM »
Is it possible  to display last post text preview only? for now its shows  recent topics and post in the same time
 and i wondering if its possible to make it display only recent post which was made under topics
 for example
 Title Topic: Recent/post
 Last post: text preview

Offline bouch

  • Just Registered
  • Posts: 1
  • SMF Version: 2.0.8
  • SP Version: 2.3.6
Re: [Block] Recent Topics/Posts with Post Preview!
« Reply #166 on: October 20, 2014, 06:01:56 AM »
Hello !

Thanks a lot for this great mod !

I have a question : is it possible to have the same layout as the original post ?

A post formatted like that :
Hello,
- one
- two
- ...

looks like :
Hello,-one-two-...


Thanks !

Offline dsystem

  • Semi Newbie
  • *
  • Posts: 6
  • SMF Version: 2.0.9
  • SP Version: 2.3.6
Re: [Block] Recent Topics/Posts with Post Preview!
« Reply #167 on: November 10, 2014, 09:38:22 PM »
[SiNaN] This script is a veritable Swiss Army knife. You can do whatever your imagination allows.

Adding the SQL t.num_replies=0 consultation  did block:

Topics Awaiting Response

Code: [Select]
<?php

/*
Block: Recent posts with post preview
Author: Blue @ Simple Portal.net
Version: 1.6
*/

/* [SETUP WHAT YOU WANT HERE] */

$topics_posts 1; // TOPICS - 1 | MESSAGES - 2
$limit 5; // How many recent posts do you want to output?
$number 70; // How many characters do you want to output?
$exclude_boards null; // 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 false// 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 "150px";
$scrollbar 0;       // ENABLE - 1 | DISABLE - 2

// Do you want to translate it to your own language? :P
$text['sportal_false'] = 'Simple Portal not found';
$text['board'] = 'in';
$text['who'] = 'by';

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

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

// Lets see if you are using Simple Portal. If not...well...go get them :D
if (!file_exists($sourcedir '/PortalBlocks.php'))
{
echo $text['sportal_false'];
return;
}

// 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 t.num_replies, 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 t.num_replies=0 AND 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'] . '&nbsp;' $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'], 'http://') ? $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'] . '&nbsp;' $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'], 'http://') ? $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 '&nbsp;<img src="'$settings['images_url'], '/'$context['user']['language'], '/new.gif" alt="new" border="0" />';

echo '<br />
<small>' 
$text['who'] . '&nbsp;' $post['username'] . '&nbsp;|&nbsp;' $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 Burke Knight

  • Sr. Member
  • ****
  • Posts: 394
  • Gender: Male
  • I tell it how I see it. Don't like it? Hit Alt+F4
    • BurkeKnight Enterprises
  • SMF Version: None
  • SP Version: None
  • Elkarte Version: None
Re: [Block] Recent Topics/Posts with Post Preview!
« Reply #168 on: December 09, 2014, 05:24:52 PM »
Is there any way to change it so instead of displaying the username for the poster, it shows the display name?

Offline mrnuke7175

  • Semi Newbie
  • *
  • Posts: 10
  • SMF Version: 2.0.6
  • SP Version: 2.3.5
Re: [Block] Recent Topics/Posts with Post Preview!
« Reply #169 on: January 31, 2015, 09:34:03 PM »
Hello !

Thanks a lot for this great mod !

I have a question : is it possible to have the same layout as the original post ?

A post formatted like that :
Hello,
- one
- two
- ...

looks like :
Hello,-one-two-...


Thanks !

I'm wondering about the same thing. :-)

Offline dtek

  • Semi Newbie
  • *
  • Posts: 13
  • SMF Version: 1.1.11
  • SP Version: 2.3.1
Re: [Block] Recent Topics/Posts with Post Preview!
« Reply #170 on: February 12, 2015, 03:53:57 PM »
The version of mod_security my host uses does not allow for user toggling and I get this error.

Not Implemented

GET to /index.php not supported.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

I have edited the .htacces file but obviously that didn't work Any ideas?

Offline ♦ Ninja ZX-10RR ♦

  • Spammer Hammer
  • Support
  • *
  • Posts: 1193
  • Gender: Male
  • Sniper Legends
    • Virtual Interactive Games Entertainment™
  • SMF Version: 2.0.13
  • SP Version: 2.3.6
  • Elkarte Version: 1.0.6
Re: [Block] Recent Topics/Posts with Post Preview!
« Reply #171 on: February 12, 2015, 04:08:19 PM »
That has nothing to deal with this block. It's an SMF issue and the solution is... Get a decent host. Try to contact them and ask them to remove that restriction, if you can.
Have you tried SimplePortal Documentation before asking? ;)
F.A.Q.  English Support  |  Blocks Support
Fancy Feature idea ?!  |  Blocks Requests
Themes & Graphics

? My job! ?No PMs for support unless it's a paid request. Thank you! :)#OpIsis

Offline dtek

  • Semi Newbie
  • *
  • Posts: 13
  • SMF Version: 1.1.11
  • SP Version: 2.3.1
Re: [Block] Recent Topics/Posts with Post Preview!
« Reply #172 on: February 12, 2015, 04:22:14 PM »
ohhhhhhhhh

I thought it did have something to deal with this block. Excuse me for not knowing it was SMF and not the Simpleportal block itself and asking for assistance. I really thought the author of the code would be a good person to ask. I guess after five days I should have known that. I did speak to the host and they can not turn it off. Maybe I shall just finish the site and move on to a new host and add the block then.

I will head over to SMF now. Thank you so very much pal.




Edit:

Actually you are dead right, I got the same reply from SMF regarding the host. Cheerz

« Last Edit: February 12, 2015, 04:34:11 PM by dtek »

Offline ♦ Ninja ZX-10RR ♦

  • Spammer Hammer
  • Support
  • *
  • Posts: 1193
  • Gender: Male
  • Sniper Legends
    • Virtual Interactive Games Entertainment™
  • SMF Version: 2.0.13
  • SP Version: 2.3.6
  • Elkarte Version: 1.0.6
Re: [Block] Recent Topics/Posts with Post Preview!
« Reply #173 on: February 12, 2015, 05:26:56 PM »
I know, I used to be there until I quitted it for some people being... Let's say "questionable", especially the high ranked ones.
Get a better host @_@ unfortunately your smf installation won't work properly if your host doesn't disable mod_security, plus they are not experienced at all if they think it's that necessary :/
You're welcome, unfortunately there is not much you can do except switching host and tell your actual one to... *insert vulgar sentence here* :P
Have you tried SimplePortal Documentation before asking? ;)
F.A.Q.  English Support  |  Blocks Support
Fancy Feature idea ?!  |  Blocks Requests
Themes & Graphics

? My job! ?No PMs for support unless it's a paid request. Thank you! :)#OpIsis

Offline 420connect

  • Jr. Member
  • **
  • Posts: 94
Re: [Block] Recent Topics/Posts with Post Preview!
« Reply #174 on: February 17, 2015, 07:57:17 PM »
Hey SP!
I'm loving this box and the idea of customising it a little bit further if possible...

I was wondering if it's able to get my smileys to 'parse' in the custom block?

also, when I try to hide boards from being included I get a very strange css error? :S
« Last Edit: March 04, 2015, 12:58:59 PM by 420connect »

Offline 420connect

  • Jr. Member
  • **
  • Posts: 94
Re: [Block] Recent Topics/Posts with Post Preview!
« Reply #175 on: March 07, 2015, 05:39:48 AM »
Still looking to parse smileys in this block but have managed to solve my excluded boards error..

Using: $exclude_boards = array(87, 93, 17, 71);

where as before I was trying to use: $exclude_boards = array( ID87, ID93, ID17, ID71);

Offline ♦ Ninja ZX-10RR ♦

  • Spammer Hammer
  • Support
  • *
  • Posts: 1193
  • Gender: Male
  • Sniper Legends
    • Virtual Interactive Games Entertainment™
  • SMF Version: 2.0.13
  • SP Version: 2.3.6
  • Elkarte Version: 1.0.6
Re: [Block] Recent Topics/Posts with Post Preview!
« Reply #176 on: March 07, 2015, 05:46:07 AM »
I might be wrong but if you added a parseSmileys maybe...? http://support.simplemachines.org/function_db/index.php?action=view_function;id=220
Have you tried SimplePortal Documentation before asking? ;)
F.A.Q.  English Support  |  Blocks Support
Fancy Feature idea ?!  |  Blocks Requests
Themes & Graphics

? My job! ?No PMs for support unless it's a paid request. Thank you! :)#OpIsis

Offline 420connect

  • Jr. Member
  • **
  • Posts: 94
Re: [Block] Recent Topics/Posts with Post Preview!
« Reply #177 on: March 16, 2015, 09:18:04 AM »
Thanks for the link Ninja although my attempts have failed to add it in properly, I'll get it solved one day! .   ;P



A new idea for this I am hoping wouldn't be too difficult..

I really like what this block offers, but would also like to use the "Advanced Unread Posts" - However I'd ideally like to keep the styling of the 2 the same.

I am wondering could anyone help with tweaking the below code to show a users unread posts, but using the same display as is below.

Code: [Select]
<?php

/*
Block: Recent posts with post preview
Author: Blue @ Simple Portal.net
Version: 1.6
*/

/* [SETUP WHAT YOU WANT HERE] */

$topics_posts 2; // TOPICS - 1 | MESSAGES - 2
$limit 100; // How many recent posts do you want to output?
$number 240; // How many characters do you want to output?
$exclude_boards = array(87931771); // 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 false// Do you need to show html special characters like Greek characters?

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

// Do you want to translate it to your own language? :P
$text['sportal_false'] = 'Simple Portal not found';
$text['board'] = 'in';
$text['who'] = 'by';

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

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

// Lets see if you are using Simple Portal. If not...well...go get them :D
if (!file_exists($sourcedir '/PortalBlocks.php'))
{
echo $text['sportal_false'];
return;
}

// 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 IFNULL(u.real_name, m.poster_name) AS 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'] . '&nbsp;' $row_posts['name'] .'" href="' $scripturl '?topic=' $row_posts['id_topic'] . '.msg' $row_posts['id_last_msg'] . ';topicseen#new">' $row_posts['subject'] . '</a>',
      
'body' => parse_bbc($row_posts['body']),
  'avatar' => $row_posts['avatar'] == '' $memberContext[$row_posts['id_member_updated']]['avatar']['href'] : (stristr($row_posts['avatar'], 'http://') ? $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 IFNULL(u.real_name, m.poster_name) AS 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'] . '&nbsp;' $row_posts['name'] .'" href="' $scripturl '?topic=' $row_posts['id_topic'] . '.msg' $row_posts['id_msg'] . ';topicseen#new">' $row_posts['subject'] . '</a>',
      
'body' => parse_bbc($row_posts['body']),
  'avatar' => $row_posts['avatar'] == '' $memberContext[$row_posts['id_member']]['avatar']['href'] : (stristr($row_posts['avatar'], 'http://') ? $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 '&nbsp;<img src="'$settings['images_url'], '/'$context['user']['language'], '/new.gif" alt="new" border="0" />';

echo '<br />
<small>' 
$text['who'] . '&nbsp;' $post['username'] . '&nbsp;|&nbsp;' $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 420connect

  • Jr. Member
  • **
  • Posts: 94
Re: [Block] Recent Topics/Posts with Post Preview!
« Reply #178 on: April 04, 2015, 06:08:28 AM »
realy nice but stil dont have the smiley's couldn't find any answer

Code: (Find) [Select]
$preview = substr ($content3,0,$number);
Code: (Replace) [Select]
$preview = substr ($content3,0,$number);
parsesmileys($preview);





edit - another little thing I'd like to add if it's not a huge job..

Currently, I use the forum's word censor to clean up a few strange characters that appear when grabbing an RSS feed. (e.g. "“" is censored to be replaced with "")

- Could I tell the block to use the same censor rules?


I should have better searched this thread before asking for the smileys fix - however I've just tested this and with the additional line, still my smileys don't show? :(
« Last Edit: April 04, 2015, 06:22:32 AM by 420connect »

Offline xeon365

  • Semi Newbie
  • *
  • Posts: 9
  • SMF Version: 2.0.5
  • SP Version: 2.3.5
Re: [Block] Recent Topics/Posts with Post Preview!
« Reply #179 on: October 01, 2015, 05:13:52 PM »
Someone got an edit to make the block, show the users actual 'Name' ..and not use the 'Username'

Even in SMF own profile it reads

"Name
This is the displayed name that people will see"

yet this block uses the username field..