Support Forum

Post time display

71 Answers

New Answer

CF Conrad_Farlow
Conrad_Farlow
Member

This is how my current V4.4.5 active forum handles time, it looks good.

 

 

This is the new forum which admittedly has a bigger font but I think that it would be fine if it had similar formatting.

 

Lee (because I am reluctant to ask these very busy people anything else) what would be the best way of having August 8th, 2011 and then 5:58pm on a new line?

Like this.

First Post:

Bra1n

August 8, 2011

5:58 pm

LH Lee H
Lee H
Member

Conrad I wish I had my server back up. I can’t play with the code at all right now 🙁

LH Lee H
Lee H
Member

I took a peek. Seems like you showed a pic of your forum view.

In spForumView.php (template) you make a call to sp_TopicIndexFirstPost() to show first poster and details. If you give args for the date and time, the date and time are written as one line. There’s no args or filters to change that. You “could” write a filter and do a preg_replace() of the span containing the date and time and convert the ‘-‘ minus or hypen to a linebreak (br) to make it two lines.

OR you could copy the sp_TopicIndexFirstPost() and custom name it, and modify the code to suite your needs.

OR you can sweet talk Andy or Steve into making that hypen whatever you want with another arg added to the core.

You would also need to do the same thing for sp_TopicIndexFirstPost()

LH Lee H
Lee H
Member

@Conrad

I was having a little fun. Paste:

function stack_date_time($out){
    return preg_replace("/(<span.*[0-9])-([0-9].*</span>)/", "$1<br />$2", $out);
}


add_filter('sph_TopicIndexFirstPost', 'stack_date_time');
add_filter('sph_TopicIndexLastPost', 'stack_date_time');

in your themes spFunctions.php

Basically its a “plugin” that will take that date/time one liner and replace the hyphen with a linebreak. I’m pretty sure it will fail (and do nothing) if you change your forums time/date format in the admin backend.

This works for “Forum View” as you pictured.

YS Yellow Swordfish
Yellow Swordfish
Member

Sorry guys – got caught up on other issues last night and I am working alone this week.
I have opened a ticket on this and will add a parameter to all date displays – ‘stack’ – which will do what you both want…

CF Conrad_Farlow
Conrad_Farlow
Member

No need to apologise Andy, seen the message from Steve about his availability.

Lee it works, I also added

add_filter('sph_ForumIndexLastPost', 'stack_date_time');

Which also works. I must admit I don’t get the sph_ prefix though.

CF Conrad_Farlow
Conrad_Farlow
Member

Oh one other thing, which is list view? I know Group view which is the first page, Forum view which gives a list of topics and topic view which shows a list of posts for that topic but I don’t know what list view is embarassed

YS Yellow Swordfish
Yellow Swordfish
Member

The prefix ‘sph’ is our identification for an SP filter or action hook.

The List View is used for a few things: The new post list whether displayed on the front page (Group View) or from any of the post list popups. It is also used for search results. And was actually used in the iForum theme to show the topic list.

YS Yellow Swordfish
Yellow Swordfish
Member

All date/times are now stackable if the date/time options are used instead of the nicedate option.

The exception is the List View. Haven’t decided about that one yet…

LH Lee H
Lee H
Member

Nice! I’ll have to check it out if and when I get a chance to svn up.

CF Conrad_Farlow
Conrad_Farlow
Member

Right so how do I do the stack? Do I have to still use a filter?

LH Lee H
Lee H
Member

The new argument is called “stackdate”. The default is 0. If changed to 1 the hypen we talked about earlier will vanish and be replaced with a linebreak (br tag).

Here’s a example from earlier with the stackdate arg included:

sp_ForumIndexLastPost('tagClass=spInRowPostLink&nicedate=0&date=1&time=1&stackdate=1',__sp('Last Post'));

Will have a linebreak.

No stackdate arg, or arg of stackdate=0 will result in a hypen and all in one line.

CF Conrad_Farlow
Conrad_Farlow
Member

Yes that works great thanks a lot Lee, and of course Andy!

YS Yellow Swordfish
Yellow Swordfish
Member

You’re welcome. These are the kinds of things we can add easily and the more we get in before we release the better for everyone.

CF Conrad_Farlow
Conrad_Farlow
Member

I agree Andy and now I know what list view is 🙂

I have a question, it’s to do with these code modifications and my theme but as it is pertinent to the time display I’ll put it here.

What is the best way of ensuring that I keep these slight customisations but keep the code up to date? I’m sure that there is probably some way of easily doing this using svn but I don’t know how. I suppose what I want to do is check in your files from the default theme into my theme and compare the differences in an editor. There must be some clever and elegant way of doing this I suspect.

Obviously this is absolutely none urgent!

Conrad