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: 275
  • 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]

Installation errors? Mod incompatibilities? Upgrade problems? Make your way over to the Install and Upgrade Support board for all your solutions!

Author Topic: Recent Post block auto refresh  (Read 18532 times)

0 Members and 1 Guest are viewing this topic.

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 #20 on: August 08, 2014, 11:02:25 PM »
Here is a new block code & a new file is attached.

PHP Block Code:
Code: [Select]
/* adjustable variables */

$block_id = 11;
$avatar_height = 25;
$avatar_width = 25;
$char_limit = 25;
$seconds_delay = 60;

$file = 'recent_posts.php';

/* do not edit below this line */
global $boarddir, $context;
list($_SESSION['blockID'], $_SESSION['avatar_height'], $_SESSION['avatar_width'], $_SESSION['char_limit']) = array($block_id, $avatar_height, $avatar_width, $char_limit);
require_once($boarddir . '/' . $file);
$delay = !empty($seconds_delay) ? ((int)$seconds_delay * 1000) : 60000;

echo '
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript">setInterval(function() {$("#sp_recent_reload_' . $block_id . '").load("' . $file . '")}, ', $delay, ');</script>';



Use the file I attached as is without altering it to see if it functions properly.

Regards.
« Last Edit: August 09, 2014, 01:27:23 AM by Underdog »

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 #21 on: August 09, 2014, 12:14:57 AM »

 :0 The text of "at" within the date variable was giving an incorrect value when I used strtotime on it because those characters were not escaped.
Anyhow, I have fixed the file. Try the attachment to the last post again as I have recently updated it.

Offline dopeitspaul

  • Semi Newbie
  • *
  • Posts: 24
  • SMF Version: 2.0.8
  • SP Version: 2.3.5
Re: Recent Post block auto refresh
« Reply #22 on: August 09, 2014, 12:40:30 AM »
^ Thanks I was going to mention about the time but you fixed it.

I don't know why but before you uploaded the new file the auto refresh was working fine. But then the new file you just uploaded, it stopped auto refreshing again. I didn't change anything in the php file either.

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 #23 on: August 09, 2014, 12:47:15 AM »

I updated the previous file again so it says "Today at ..." when someone hovers on the date.
I just tested this and it is working fine for me atm.

Regards.

Offline dopeitspaul

  • Semi Newbie
  • *
  • Posts: 24
  • SMF Version: 2.0.8
  • SP Version: 2.3.5
Re: Recent Post block auto refresh
« Reply #24 on: August 09, 2014, 02:35:33 AM »
Everythings looking good thanks !

Do you happen to know why the time messes up whenever I try to edit the php? I tried editing and then each time showed was "Wednesday 4:00pm"

I backspace all the words I typed and have it back to normal but the time is still messed up.

The only solution was to download the php file again, and put it in the ftp.

I never knew things like that can happen. First time experiencing it.

Offline dopeitspaul

  • Semi Newbie
  • *
  • Posts: 24
  • SMF Version: 2.0.8
  • SP Version: 2.3.5
Re: Recent Post block auto refresh
« Reply #25 on: August 12, 2014, 01:04:00 PM »
Help, this is the time error I was talking about.

Wednesday 4:00PM just started appearing on my site


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 #26 on: August 12, 2014, 04:13:59 PM »
dopeitspaul,

  Imo the php file code is being adjusted & causing the issue. This does not occur if you use the file I provided without changing it. Ii is difficult to keep posting new files as you periodically change your preference for the date format and/or title/hover format which I have witnessed by checking up on your site.
 
« Last Edit: August 12, 2014, 04:21:08 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 #27 on: August 12, 2014, 05:47:35 PM »
God damn, I screwed up. Sorry. Now the title of the topic is screwed up too. I tried downloading your attachment again but still resulted the same. Can you attach the same file but with some changes?



First row with the title topic, can you make the font size 11px and bold?

Second row with the author, can you make the font size 10px?

Third row with the date, can you the font size 10px? This time without the bold and the "|" inbetween.

And can you remove the "<hr />" line.
As you can see here I removed the line. I replaced it with a <br /> but I'm not even sure if that did anything



If you can re upload it again, I promise I won't touch the file ever. 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 #28 on: August 12, 2014, 06:44:30 PM »
Quote
Imo the php file code is being adjusted & causing the issue. This does not occur if you use the file I provided without changing it.


  You can edit your own files and what I meant was that your issues with the display do not appear to be caused by what I have posted. I have been testing the same file for days now on live & local installs.
 
« Last Edit: August 12, 2014, 06:54:12 PM by Underdog »

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 #29 on: August 12, 2014, 07:27:59 PM »
  The auto refresh of the block appears to be working when I test it.
For testing I seem to have no issues with the display date for today or any other day thus far.
Here is another file that may resolve the date display issue.
« Last Edit: August 12, 2014, 08:11:35 PM by Underdog »

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 #30 on: August 12, 2014, 07:45:29 PM »
I can see you are attempting to manually edit the title display of the time.
Imo you are editing $item['time'] directly? This could be why it is not display properly for you.
The file in the last post has been updated yet again.

I edited the display & title to what you are attempting to change it to.
Use the following lines of code to change the formats:
Code: [Select]
if (stripos($item['time'], 'today') !== false)
{
$display = 'Today ' . date('h:i A', strtotime($item['time']));
$display_title = 'Today ' . date('h:i A', strtotime($item['time']));
}
else
{
$display = date('l h:i A', strtotime($item['time']));
$display_title = date('M d, Y / D h:i A', strtotime($item['time']));
}

Here is a link regarding PHP date syntax:
http://php.net/manual/en/function.date.php
« Last Edit: August 12, 2014, 08:15:49 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 #31 on: August 12, 2014, 09:33:46 PM »
Sorry for some reason, nothing changed.
I'm currently using the attachment you recently uploaded.

Here's what the code looks like regarding the time



I have no idea why the date on the yellow block is displayed like that when I hover my mouse on that date. I just noticed it when taking this screen shot.


What I noticed before. Is that if I replaced a line with something else. The line that I replaced, will sometimes reappear whenever I open the file up again. Only sometimes though. Like for example I put the file you recently attached to my ftp replacing the old. But somehow it still had this code when I opened it.

Code: [Select]
foreach ($items as $item)
{
if (strpos($item['time'], $txt['today']) !== false)
$day = 'Today';
else
$day = date('l', strtotime(strip_tags($item['time'])));

$item['time'] = str_replace(array('<strong>', '</strong>'), '', $item['time']);
echo '

But I copy all from your recently uploaded file and pasted it on the php file in ftp. And the screenshot you see is the result. So maybe there's something wrong with my file since that glitch happens?

Here's an attachment of my php

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 #32 on: August 12, 2014, 09:39:02 PM »
Quote
But I copy all from your recently uploaded file and pasted it on the php file in ftp. And the screenshot you see is the result. So maybe there's something wrong with my file since that glitch happens?

  Are you saying you are manually copying the actual code or the file itself? This statement sounds as though you are copying the code from the file into another. If you are using a proper editor like Notepad++ (NOT notepad) that would be ok I suppose but is not necessary. You should be downloading the file and then uploading that file to your main forum directory.

  If you attempted to copy/paste/edit the actual code with an improper editor this would cause character code issues and will not work properly. Also I changed the file since last you download it so you should d/l it yet again.
 
« Last Edit: August 12, 2014, 09:51:27 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 #33 on: August 12, 2014, 10:07:39 PM »
Yeah, I upload your attachment to my ftp. But sometimes, right when I open the file without any edits, the file might still have some codes from the old file. But this only happens sometimes though. I just thought of telling you this because maybe it was the reason why this problem is happening.

Anyway, I uploaded the file you just attached. Its still the same result. Damnit  :dead:


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 #34 on: August 12, 2014, 10:21:35 PM »

It is my fault for using the time index from the array instead of the timestamp.
The format I was attempting to convert from $item['time'] was returning as false (rendering the Epoch start which is Wed, Dec 31, 1969) because it could not understand the commas within that particular date format. I did not realize the array contains the actual timestamp which is what should be used. My apologies for that .. I should have printed the full array prior to this to notice it.

Try the attachment to this file which should work for you now.

Offline dopeitspaul

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

Will get back to you if anything happens. Not gonna bother touching the file