Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Custom field date => sort threads by this date ?
cakissimo Offline
Junior Member
**
Posts: 26
Joined: Mar 2014
Post: #1
Custom field date => sort threads by this date ?
Hello,

I don't speak english very well, so sorry for this

I "build" a forum dedicated to referencing french free contests (list of websites promotions to win price...) and members who posted a thread have a Textbox field (with a Text Mask Filter to DATE ) MUST be completed.

This date is the deadline for participation for each contest...i'm looking for a way to sort thread by "deadline for participation" ,it would be much easier for my moderators to remove the finished contests topics.

...and maybe after that ,ideally, it's was a way to automatically move or delete topics with time exceeded ?

Tell me if my question is not understandable...
Thanks


Attached File(s) Thumbnail(s)
   
(This post was last modified: 04-12-2014 04:46 AM by cakissimo.)
04-12-2014 04:12 AM
Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #2
RE: Custom field date => sort threads by this date ?
If you want sorting, you'll need to make a numerical field for the date.
Use the Integer data type (note, if you change your existing field, you'll lose any stored data!) and use the input/output conversion functions to convert to/from a textual date.

It's a little tricky to do unfortunately.

Example input formatter:

Code:
<?=strtotime({VALUE})?>

Example output formatter:

Code:
<?=date('r', {VALUE})?>


My Blog
04-13-2014 06:54 PM
Find all posts by this user Quote this message in a reply
cakissimo Offline
Junior Member
**
Posts: 26
Joined: Mar 2014
Post: #3
RE: Custom field date => sort threads by this date ?
Thank for you answer...i make few test and all is not clear for me :/

I complete field with "04/11/1983" result is "11 04 1983" ...result must be "04 novembre 1983" or "04 11 1983" (put text input display format on standby for the moment...is not really a problem)
How output a french date format day/month/year ?
...i'm test with this, without succes :
Quote:<?=date('d m Y', {VALUE})?>

So, after this problem ,I don't understand how sort thread by this date after that too? can you tell me more explications please ?


"make a numerical field"...don't understand... i have make a Textbox field (with a Text Mask Filter to DATE ), is not good?


I have make few search in this forum and i don't see any exemples who can help me...
(This post was last modified: 04-13-2014 10:28 PM by cakissimo.)
04-13-2014 08:17 PM
Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #4
RE: Custom field date => sort threads by this date ?
Now that I think about it, you can probably sort by text, but the date needs to be inputted differently.
If you want to do this, ignore what I said above, and use a custom text mask filter:

Code:
^((?:19|20)\d\d)/(0?[1-9]|1[012])/(0?[1-9]|[12]\d|3[01])$

This will allow "1983/11/04" - which makes it sortable.

Note that if you already have existing data, you'll need to convert it to the new format.
For the output format, try something like:

Code:
<?=date('d F Y', strtotime({VALUE}))?>


Sorting is explained in the supplied documentation (the "Documentation" folder in the XThreads download package).
Basically, just reuse MyBB's sortby parameter, eg "forumdisplay.php?fid=2&sortby=tf_myfield"


My Blog
04-14-2014 02:45 PM
Find all posts by this user Quote this message in a reply
cakissimo Offline
Junior Member
**
Posts: 26
Joined: Mar 2014
Post: #5
RE: Custom field date => sort threads by this date ?
I have try your solution and that don't work...output display is always "01 January 1970"

But with this

Code:
^((?:19|20)\d\d)/(0?[1-9]|1[012])/(0?[1-9]|[12]\d|3[01])$

and

Code:
<?=date('d m Y', {VALUE})?>

With this code if i put 2015/12/30 on field, the result is 30 12 2015..it's ok for french format display. But the input method YYYY/MM/DD is bad for french people, i need dd/mm/yyyy input and dd/mm/yyyy output.

Is almost perfect, it's just the input format who is strange for us, so a solution will be add a datepicker jquery...i will try this.

Quote:Sorting is explained in the supplied documentation (the "Documentation" folder in the XThreads download package).
Basically, just reuse MyBB's sortby parameter, eg "forumdisplay.php?fid=2&sortby=tf_myfield"
I'm stupid...for this the problem is solved, that work well ^^

Thank you
(This post was last modified: 04-15-2014 04:58 AM by cakissimo.)
04-14-2014 07:02 PM
Find all posts by this user Quote this message in a reply
cakissimo Offline
Junior Member
**
Posts: 26
Joined: Mar 2014
Post: #6
RE: Custom field date => sort threads by this date ?
I finally use datepicker jquery for the input format.

I up this topic beacause i'm looking for how make a "Daily task" who move topics to "trash forum" if the deadline exceeded ? is it possible ?

Thank
(This post was last modified: 10-22-2014 07:29 PM by cakissimo.)
10-22-2014 07:27 PM
Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #7
RE: Custom field date => sort threads by this date ?
Unfortunately you'd need a custom script to go through all the threads and check the date and consider what to do with it.
If moderators are setting the time, you might be able to use the delayed moderation feature.

My Blog
10-24-2014 03:51 PM
Find all posts by this user Quote this message in a reply
cakissimo Offline
Junior Member
**
Posts: 26
Joined: Mar 2014
Post: #8
RE: Custom field date => sort threads by this date ?
(10-24-2014 03:51 PM)ZiNgA BuRgA Wrote:  Unfortunately you'd need a custom script to go through all the threads and check the date and consider what to do with it.
If moderators are setting the time, you might be able to use the delayed moderation feature.


Thank you, i do a daily php cronjob, it work well but....
(thread is automatically moved if dateline is exceeded and goes to trashbin forum)

...but the moved thread is blank (firstpost only..the firstpost contain only custom xthread fields), i can i fix this please ?
When a edit this blank post i see my xthread fields..so xthread data are not loose, just invisible...need to complete this query, i have forget a thing....

This is my query (i use classic mysql query, this php file is not join to mybb pages):

PHP Code:
1
2
3
4
5
6
UPDATE threads 
	LEFT JOIN threadfields_data
	ON threads.tid=threadfields_data.tid
	SET threads.fid='61' 
	WHERE threads.fid='8'
	AND testdate < UNIX_TIMESTAMP()";

(This post was last modified: 11-22-2014 12:20 AM by cakissimo.)
11-22-2014 12:05 AM
Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #9
RE: Custom field date => sort threads by this date ?
It can't be done properly with just a query, since counters etc will get messed up.
But for your particular issue, I suspect it's perhaps a template?

My Blog
11-22-2014 12:36 PM
Find all posts by this user Quote this message in a reply
cakissimo Offline
Junior Member
**
Posts: 26
Joined: Mar 2014
Post: #10
RE: Custom field date => sort threads by this date ?
"counters" is not really a problem ..it's easy to rebuild Smile

Quote: I suspect it's perhaps a template?

Yes yes, this is it... all work but my custom template "postbit_first_classic"  is not display when i move thread automatically. (but why template "editpost_first" work?)

If i move manually this thread to another forum it working again, and if i move manually yet it to trashbin it work too....

Why original "postbit_first_classic" is display rather the custom templates  ?

Original thread
https://dl.dropboxusercontent.com/u/1420...https://dl.dropboxusercontent.com/u/14206866/screens
After automatically move
https://dl.dropboxusercontent.com/u/1420...https://dl.dropboxusercontent.com/u/14206866/screens
Edit mode from trashbin forum ("blank" post)
https://dl.dropboxusercontent.com/u/1420...https://dl.dropboxusercontent.com/u/14206866/screens
(This post was last modified: 11-22-2014 06:52 PM by cakissimo.)
11-22-2014 06:39 PM
Find all posts by this user Quote this message in a reply

« Next Oldest | Next Newest »

 Standard Tools
Forum Jump: