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: 381
  • 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: Recent Post block auto refresh  (Read 17996 times)

0 Members and 1 Guest are viewing this topic.

Offline dopeitspaul

  • Semi Newbie
  • *
  • Posts: 24
  • SMF Version: 2.0.8
  • SP Version: 2.3.5
Recent Post block auto refresh
« on: August 07, 2014, 03:34:57 AM »
Hey everyone I requested this mod on simple machine forum but I was redirected to post the request on this forum.

I want to know how I can make my recent post auto refresh instead of manually refreshing the page to get the recent post updated.

Simliar to this
https://www.youtube.com/watch?v=mTaR1HgFKjE

Can anyone help me? Thanks!

Offline Chen Zhen

  • The Underdog
  • Operations Manager
  • *
  • Posts: 1350
  • Gender: Male
  • Kinesis
    • WebDev
  • SMF Version: 2.1
  • EhPortal Version: 1.22
Re: Recent Post block auto refresh
« Reply #1 on: August 07, 2014, 09:22:10 AM »
Yes this is possible.
For now I have made something that will work for you that I may develop further at some point.
Please follow these steps:

  • download the attachment and place it in your main SMF directory (ie. via FTP)
  • create a recent posts or topics block and configure it as you wish
  • ensure that this recent posts/topics block is disabled but do note the block_id number
  • create a custom PHP block and put the code shown below within the block code input
  • adjust the $_SESSION['blockID'] variable to the integer of the block_id that belongs to the disabled recent/posts block

Custom PHP block code:
Code: [Select]
$_SESSION['blockID'] = 11;
$file = 'recent_posts.php';

global $boarddir;
require_once($boarddir . '/' . $file);

echo '
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>setInterval(function() {$("#sp_recent_reload_' . $_SESSION['blockID'] . '").load("' . $file . '")}, 60000);</script>';




What you do is configure the custom PHP block (shown above) where you want it to appear
 on your forum (leave this block enabled).
You will have to adjust the disabled posts/topics block settings to what is desired for display.

Regards.
« Last Edit: August 07, 2014, 04:02:54 PM by Underdog »

Offline dopeitspaul

  • Semi Newbie
  • *
  • Posts: 24
  • SMF Version: 2.0.8
  • SP Version: 2.3.5
Re: Recent Post block auto refresh
« Reply #2 on: August 07, 2014, 01:15:03 PM »
It works but theres a problem. It won't stop refreshing! The it keeps showing the refreshing icon and won't stop

here's the image of the icon I'm talking about

Offline dopeitspaul

  • Semi Newbie
  • *
  • Posts: 24
  • SMF Version: 2.0.8
  • SP Version: 2.3.5
Re: Recent Post block auto refresh
« Reply #3 on: August 07, 2014, 01:55:27 PM »
Update, now sometimes the index page won't load.

You think theres a way to make only the <div> of that block auto refresh instead of the whole page?


Offline Chen Zhen

  • The Underdog
  • Operations Manager
  • *
  • Posts: 1350
  • Gender: Male
  • Kinesis
    • WebDev
  • SMF Version: 2.1
  • EhPortal Version: 1.22
Re: Recent Post block auto refresh
« Reply #4 on: August 07, 2014, 03:57:20 PM »
It does not refresh the entire page. The jQuery code within the block only reloads the php file which does the db query and then displays the data.
Either you did not follow instructions correctly or perhaps there is something else on the page conflicting with the jQuery load somehow.

I just tested this locally and on my live forum whereas it works fine.
I adjusted the attached file slightly since I had the db query for the block misconfigured slightly which is now fixed. Although this would not have caused the issue you describe as it was merely setting the necessary variables as defaults before my fix. I also adjusted the block code to refresh every 60000 mS which is less strain on the server.
Try the new file attachment & block code. 

Note that this:
Code: [Select]
$_SESSION['blockID'] = 11;

.. from the example has to be set to your specific block_id and not 11 (unless it happens to be that block_id).
« Last Edit: August 07, 2014, 04:04:41 PM by Underdog »

Offline dopeitspaul

  • Semi Newbie
  • *
  • Posts: 24
  • SMF Version: 2.0.8
  • SP Version: 2.3.5
Re: Recent Post block auto refresh
« Reply #5 on: August 07, 2014, 05:54:04 PM »
It works! Thanks!

I got a couple more questions.

- How can I remove this (circled in purple). Not a huge when of it. I know theres gonna be some topic titles with a long name. Is it possible to set a character limit on the block. For example, when a character exceeds the limit it ends up as [...] instead?






- And I was wondering if I could add the poster's avatar on the very left side of the block? Was thinking I should add like a 25px x 25px avatar icon.


Please let me know, appreciate all the help so far thanks!

Offline Chen Zhen

  • The Underdog
  • Operations Manager
  • *
  • Posts: 1350
  • Gender: Male
  • Kinesis
    • WebDev
  • SMF Version: 2.1
  • EhPortal Version: 1.22
Re: Recent Post block auto refresh
« Reply #6 on: August 07, 2014, 06:43:38 PM »
I'll post back with an adjustment to show the avatar when I have time later tonight.
To get rid of the scroll bar edit the custom PHP block and on the bottom right corner you will see an input titled Custom Body Style.
Put the following css attribute code in that input and save the block again:
Code: [Select]
overflow: hidden;

Regards.

Offline Chen Zhen

  • The Underdog
  • Operations Manager
  • *
  • Posts: 1350
  • Gender: Male
  • Kinesis
    • WebDev
  • SMF Version: 2.1
  • EhPortal Version: 1.22
Re: Recent Post block auto refresh
« Reply #7 on: August 08, 2014, 12:13:01 AM »
Use the file I attached to this post and this new block code:
Code: [Select]
$_SESSION['blockID'] = 20;
$_SESSION['avatar_height'] = 25;
$_SESSION['avatar_width'] = 25;
$seconds_delay = 60;

$file = 'recent_posts.php';

global $boarddir, $context;
require_once($boarddir . '/' . $file);
$delay = !empty($seconds_delay) ? ((int)$seconds_delay * 1000) : 60000;
echo '
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>setInterval(function() {$("#sp_recent_reload_' . $_SESSION['blockID'] . '").load("' . $file . '")}, ', $delay, ');</script>';




You now enter the image dimensions and the delay time (in seconds) within the block code shown above.  For this example I selected 25 x 25 (px) for the avatar images and a 60 second delay time.
Do not forget to adjust $_SESSION['blockID'].
If the height or width is set to 0 or not included it will not display any user avatars.


Regards.
« Last Edit: August 08, 2014, 09:24:59 AM by Underdog »

Offline dopeitspaul

  • Semi Newbie
  • *
  • Posts: 24
  • SMF Version: 2.0.8
  • SP Version: 2.3.5
Re: Recent Post block auto refresh
« Reply #8 on: August 08, 2014, 01:49:28 AM »
Somehow it's not working. I put the attachment file on my ftp and overwrote it on the old file. Then made a php block with the id too.

It keeps saying
"Database error in block code. Please check the code."

Offline Chen Zhen

  • The Underdog
  • Operations Manager
  • *
  • Posts: 1350
  • Gender: Male
  • Kinesis
    • WebDev
  • SMF Version: 2.1
  • EhPortal Version: 1.22
Re: Recent Post block auto refresh
« Reply #9 on: August 08, 2014, 09:20:58 AM »
I made a minor typo in the block code from the previous post.
Also I added another condition in the php file although Imo it wasn't entirely necessary.
Try to use what is posted in that block code now and the newer file.

Regards.
« Last Edit: August 08, 2014, 09:26:19 AM by Underdog »

Offline dopeitspaul

  • Semi Newbie
  • *
  • Posts: 24
  • SMF Version: 2.0.8
  • SP Version: 2.3.5
Re: Recent Post block auto refresh
« Reply #10 on: August 08, 2014, 01:54:33 PM »
It's working thanks!

But the aligning has one thing overlapping the other.
I noticed on the php file I downloaded. There were some class in the file like <td class="sp_recent_info sp_right">, and <td class="sp_recent_icon sp_center">

Where in the css files can I edit those? I even tried adding my own div class on the file but nothing happened

Also is there a way I can add a character limit on the topic title followed by a "..."?
« Last Edit: August 08, 2014, 03:20:34 PM by dopeitspaul »

Offline Chen Zhen

  • The Underdog
  • Operations Manager
  • *
  • Posts: 1350
  • Gender: Male
  • Kinesis
    • WebDev
  • SMF Version: 2.1
  • EhPortal Version: 1.22
Re: Recent Post block auto refresh
« Reply #11 on: August 08, 2014, 03:20:05 PM »

For the compact view (side block) I attempted to use some css to center the avatar compared to the text to the right if it however I only tested this in the Chrome browser. You can adjust the em measurement to a lesser amount or omit the css for the avatar altogether.

Within the php file look for this:
Code: [Select]
<span style="position: relative;bottom: -0.5em;">

Either change it to ie. -0.2em or perhaps just omit the css and change it to:
Code: [Select]
<span>

Omitting the css for that span container will cause the bottom of the image to be aligned with the text beside it.

Regards.

Offline Chen Zhen

  • The Underdog
  • Operations Manager
  • *
  • Posts: 1350
  • Gender: Male
  • Kinesis
    • WebDev
  • SMF Version: 2.1
  • EhPortal Version: 1.22
Re: Recent Post block auto refresh
« Reply #12 on: August 08, 2014, 03:32:32 PM »
Here is another block code & file with some adjustments.
The newer file will now use the SMF default theme's post icon in place of an avatar when a user does not have one selected. Imo it is aesthetically more sound that way.

Code: [Select]
$_SESSION['blockID'] = 20;
$_SESSION['avatar_height'] = 25;
$_SESSION['avatar_width'] = 25;
$seconds_delay = 60;

$file = 'recent_posts.php';

global $boarddir, $context;
require_once($boarddir . '/' . $file);
$delay = !empty($seconds_delay) ? ((int)$seconds_delay * 1000) : 60000;
echo '
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>setInterval(function() {$("#sp_recent_reload_' . $_SESSION['blockID'] . '").load("' . $file . '")}, ', $delay, ');</script>';
« Last Edit: August 08, 2014, 03:50:25 PM by Underdog »

Offline dopeitspaul

  • Semi Newbie
  • *
  • Posts: 24
  • SMF Version: 2.0.8
  • SP Version: 2.3.5
Re: Recent Post block auto refresh
« Reply #13 on: August 08, 2014, 04:33:49 PM »
How can I align the Topic, Name, and Time, and move it more on the right?


In the php file I was playing around with this.

Code: [Select]
(!empty($avatar[$item['poster']['id']]) ? '<span style="position: relative;bottom: -0.1em;">' . $avatar[$item['poster']['id']] . '&nbsp;</span>' : ''), '<a href="', $item['href'], '">', $item['subject'], '</a> <span class="smalltext">', $txt['by'], ' ', $item['poster']['link'], $item['new'] ? '' : ' <a href="' . $scripturl . '?topic=' . $item['topic'] . '.msg' . $item['new_from'] . ';topicseen#new" rel="nofollow"><img src="' . $settings['lang_images_url'] . '/new.gif" alt="' . $txt['new'] . '" border="0" /></a>', '<br />[', $item['time'], ']</span><br />', empty($item['is_last']) ? '<hr />' : '';

I removed the "span class" and changed it to "span style" and then I started adding some css codes in it but nothing happened. I thought it would work because you were allowed to do it in regards to the avatar.

Anyway here's how it looks like



Here's an idea of how I wanted it to look like



Is there a way I can add my own css codes to the Title, Name, and Date in order for me to make this happen?

Offline Chen Zhen

  • The Underdog
  • Operations Manager
  • *
  • Posts: 1350
  • Gender: Male
  • Kinesis
    • WebDev
  • SMF Version: 2.1
  • EhPortal Version: 1.22
Re: Recent Post block auto refresh
« Reply #14 on: August 08, 2014, 06:25:29 PM »
You need to display the compact block html in a table or use css elements to mimic one.
Also your example posted at SMF uses the text of Re: and not Topic: and does not include the time. 
Is the image you gave in the last post the exact specifics of what you request?

I am assuming you are using this in a side block (compact view). Do you have side blocks on either side of your forum or just on one side? The reason I ask this is because the example you posted at SMF  has blocks only on the right side and limits topic/subject length for aesthetics. If you want it to appear like this then I need to know how many characters to limit it to or perhaps I can include that integer at the start of your block code which you can adjust.

If you have just right blocks and I limit the character length for the lines containing the topic and member those lines that exceed the limit will be finished with three dots ( ... ). However this will not look proper for the date/time display if that occurs. May I suggest a different date/time format? If I make it slashes for that, how do you want it displayed? d/m/y ??
« Last Edit: August 08, 2014, 06:35:47 PM by Underdog »

Offline dopeitspaul

  • Semi Newbie
  • *
  • Posts: 24
  • SMF Version: 2.0.8
  • SP Version: 2.3.5
Re: Recent Post block auto refresh
« Reply #15 on: August 08, 2014, 08:01:15 PM »
You need to display the compact block html in a table or use css elements to mimic one.
Is the image you gave in the last post the exact specifics of what you request?

Alright, how do I do that?
And not exactly as the image above. I put the example below


Quote
I am assuming you are using this in a side block (compact view). Do you have side blocks on either side of your forum or just on one side? The reason I ask this is because the example you posted at SMF  has blocks only on the right side and limits topic/subject length for aesthetics. If you want it to appear like this then I need to know how many characters to limit it to or perhaps I can include that integer at the start of your block code which you can adjust.

I'm only using the right side block for the recent post. And yeah, can you just intergrate the character limit on the block code. Here's the link to my forum: http://indieraptalk.com/forum/

Quote
If you have just right blocks and I limit the character length for the lines containing the topic and member those lines that exceed the limit will be finished with three dots ( ... ). However this will not look proper for the date/time display if that occurs. May I suggest a different date/time format? If I make it slashes for that, how do you want it displayed? d/m/y ??

You think it's possible to just show the Day and the hours? 
Here's an example:

a   Re: SimplePortal...
v   By: Dopeitspaul
y   Monday | 4:00PM

And when it says the days like "monday" "tuesday" etc, can you make it bold too just like when "today" is displayed.

Thanks!

Take your time, I feel bad for asking all of these request


Offline Chen Zhen

  • The Underdog
  • Operations Manager
  • *
  • Posts: 1350
  • Gender: Male
  • Kinesis
    • WebDev
  • SMF Version: 2.1
  • EhPortal Version: 1.22
Re: Recent Post block auto refresh
« Reply #16 on: August 08, 2014, 08:21:59 PM »

Quote
a   Re: SimplePortal...
v   By: Dopeitspaul
y   Monday | 4:00PM

What is a, v and y ??
Is that literally what you want?

Offline dopeitspaul

  • Semi Newbie
  • *
  • Posts: 24
  • SMF Version: 2.0.8
  • SP Version: 2.3.5
Re: Recent Post block auto refresh
« Reply #17 on: August 08, 2014, 08:31:45 PM »

Quote
a   Re: SimplePortal...
v   By: Dopeitspaul
y   Monday | 4:00PM

What is a, v and y ??
Is that literally what you want?

Haha sorry, it's just an example of the height of the avatar. "avy"

Offline Chen Zhen

  • The Underdog
  • Operations Manager
  • *
  • Posts: 1350
  • Gender: Male
  • Kinesis
    • WebDev
  • SMF Version: 2.1
  • EhPortal Version: 1.22
Re: Recent Post block auto refresh
« Reply #18 on: August 08, 2014, 08:45:33 PM »
A new file is attached along with the block code shown below.

PHP Block code:
Code: [Select]
$_SESSION['blockID'] = 20;
$_SESSION['avatar_height'] = 25;
$_SESSION['avatar_width'] = 25;
$_SESSION['char_limit'] = 30;
$seconds_delay = 60;

$file = 'recent_posts.php';

global $boarddir, $context;
require_once($boarddir . '/' . $file);
$delay = !empty($seconds_delay) ? ((int)$seconds_delay * 1000) : 60000;
echo '
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>setInterval(function() {$("#sp_recent_reload_' . $_SESSION['blockID'] . '").load("' . $file . '")}, ', $delay, ');</script>';

You can adjust that character limit at the top of the block code. For this example I used a 30 character limit (for topic name and author name) which you can adjust to what works best for your forum.

Regards.

Offline dopeitspaul

  • Semi Newbie
  • *
  • Posts: 24
  • SMF Version: 2.0.8
  • SP Version: 2.3.5
Re: Recent Post block auto refresh
« Reply #19 on: August 08, 2014, 09:35:36 PM »
Thanks! The aligning looks great.

There's a couple problems I noticed though. Somehow when I post for today, the day says "Wednesday" instead of "today". But the old post that aren't from today is accurate though.

And I tested it out if it would auto refresh but somehow its not doing it. I have one tab open waiting for it to refresh while I have another tab making a post but nothings happening. I even waited 60 seconds just like the code says too.