Support Forum

Time in Recent Post Widget

HA Hari
Hari
Member

Sorry for a bunch of small questions today. But today is “rollout” day for the new forum and my members generate a lot of questions I cant answer. This will fade in the coming days. 🙂

Is there an easy way in the Recent Post Widget to not only display the date, but also the time of the post shown?

This is something missed from the old mingle recent post list.

Maybe I can add some html code in the date-field of the widget to add the time?

Any idea?

18 Answers

New Answer

YS Yellow Swordfish
Yellow Swordfish
Member

The only way would be to change the php code in the source tag. If you want to go ahead and do that I can tell you where to go…

HA Hari
Hari
Member

Yes pls tell me. If its not to complicated I might make an exception.

Thanks!

YS Yellow Swordfish
Yellow Swordfish
Member

The code file is in the forum-plugins folder /template-tags/library/sp-RecentPosts-tag.php

The date section is commented. The function:

sp_date('d', $spThisListTopic->post_date)

is also used to display the time by simply changing the ‘d’ to a ‘t’ – so you can repeat the call on that line of code. Something along the lines of:

$out.= "<span class='$textClass'>".$beforeDate.sp_date('d', $spThisListTopic->post_date)." - ".sp_date('t', $spThisListTopic->post_date)."$afterDate</span>
";

for example

HA Hari
Hari
Member

Happy new year!

Found the time to try and works! Thanks, this was one of the issues, many of my readers where complaining about, because the navigation is mostly done via the sidebar of “recent posts”.

What is the easiest way to automate the change, so that I dont need to do it with every update? Do I need a child theme anyhow or is there a simpler, quicker way to permanently incorporate this?

YS Yellow Swordfish
Yellow Swordfish
Member

I have no advice on automating code changes to core files I am afraid. As we always say to people – changes like that are really up to you – there really isn’t anything we can do to help with that.

HA Hari
Hari
Member

One additional question I became aware of after the change.

I have set the limit to 30 “items” in the widget.

But shown are only 17 topics with new posts within the timespan of two days.

Question:

What does the number of items count. The topics or the posts? If posts I could understand the 17, if 30 posts are part of only 17 topics.

Or is there an inherent timecount, that cuts anything beyond 24 hours?

Thanks!

MP Mr Papa
Mr Papa
Member

No, there is no time limit applied to the recent posts tag…

not sure what you mean by ‘items’?  assume you mean the ‘limit’ option in the widget?  would probably be useful to see a screenshot of your widget options…

it should be posts not topics that gets limited…

HA Hari
Hari
Member

MrPapa, thanks for the answer.

There are different issues here. I try to structure my post into 4 sections, to prevent mixing different issues:

(1) “Item” vs topic or post

I used the undefinded phrase “Item”, because that is what you yourself use in the comment section of the sp-recentposts-tag.php, to explain what the count is supposed to do:

limit: How many items to show in the list number

I was not able to find a concret reference, whether “items” are “topics” or “posts” and that was part of my question. Maybe you should change that comment/explanation, to be more precise.

(2) Conclusion from your information

From your answer I understand, that “items” means posts. Meaning in a concrete example:

Assuming I have set the limit to “20” and the last 20 posts in the forum, spread over 8 topics only , then the Recent Post Widget will only show 8 entries in the sidebar.

Is this a correct conclusion?

(3) “Bug” with the change proposed from Yellow Swordfish?

Yellow Swordfish was so nice above, to provide code to add a timestamp to the date in the recent post widget.

This is *very* important in my setup, many user were complaining, because navigation of the latest posts in my setup is in most cases done via this sidebar. Without the timestamp, you never know, whether the same author posted another post in a given topic – or not. As I said, many were complaining, I could send you a long list in german. 😉

With the change from Yellow Swordfish, that I incorporated into sp-recentposts-tag.php, everything seemed to work fine at the first glance.

But….

Now I always have *only* 17 entries in the sidebar. And that independent of whether I put 30, 50 or even 100 in the limit.

I added a picture of the widget settings as an attachement, with “100” as limit. Still I only get “17” topics displayed.

And no, please believe me, there are much more topics than 17 as part of the last 100 posts. I checked that. Something is going wrong with the change I did as proposed by Yellow Swordfish.

(4) Request to add the “time” as option into the core

Yellow Swordfish made clear above, that there is no way to automate the changes made and preventing me from doing this change over and over again with every update. Reason seems to be, that the core is involved here.

On the other hand, to me it is an important feature and it seems, as if it is not much work to include the “time” as an option into the widget.

Therefore I hereby respectfully request to add the “time” as an display option to the widget in the core.

Thanks! Hari

MP Mr Papa
Mr Papa
Member

# 2 yes, that is the correct conclusion…

# 3 I see now way for Andy’s change to have affected the number of recent posts shown – it does not affect a count, it simply adds more time to display to the existing entries…  Are you saying you have confirmed if you remove Andy’s change that you get a different count of entries???

@yellow-swordfish  any chance topic cache (ie https://simple-press.com/support-forum/sp5-plugin-topics/recent-forum-posts-widget-not-updating-new-posts-on-homepage-help/page-3/#p158376) could be involved here?

HA Hari
Hari
Member

Mr Papa,

First: you are right, the problem has nothing to do with the added line for “time” as proposed by Andy. As a test, I reversed to the orginal version and that had no effect on above behaviour. Obviously it got my attention first after the change, but had nothing to do with it.

Second: But the strange behaviour persists. As of now, I have 19 entries, even after I changed the limit to 1.000 (thousand) posts as a test. You can be sure, I have far more than 19 topics in the forum, even within the last week.

But independend of what I put into the limit, the number of topics shown in the sidebar stays the same, no difference between a limit of 40 and a limit of 1.000

Also I should note, that the timespan that is shown, is always 2 full days plus a few hours. Today is sunday evening here, so shown topics go back to midth of friday as of now, but not beyond, even not with a “thousand” as limit.

Question: So obviously, there must be “something” restricting the number of topics shown. The behaviour looks like a time-limit, with for example, posts beyond 52 hours not displayes any more.

But you said, there is no such thing as a time limit in the plugin. But “something” must be there, otherwise, with a limit of 1.000, I should get hundreds of topics, but not just 19 as of now.

What can that be? And how do I remove this limit?

YS Yellow Swordfish
Yellow Swordfish
Member

It would be a staggering coincidence but might you have the same issue as this user:

https://simple-press.com/support-forum/sp5-plugin-topics/recent-forum-posts-widget-not-updating-new-posts-on-homepage-help/page-3/#p158376

HA Hari
Hari
Member

Thanks. I was already aware of this thread when searching for a possible cause, but never really understood what the user meant with “not showing on my homepage”.

To clarify, I have no odd behaviour on new posts in the forum. They show up, they count, everything seems fine as far as I recognize things, just the recent post plugin stops to display them after 2 days plus some hours.

But just to be sure, I as of this moment checked via PHPMyAdmin the database table you mentioned in that thread.

I can only see one instance of meta-type = topic_cache.

So it seems, as if this is something different. I am open to all suggestions. Maybe you could test the scenario on your forum. If you put a large number in the limit, what happens? Does the plugin show topics that are a week old too?