Search

Hi

I’m creating a commenting wall which I want to auto update using AJAX. I have an idea in my mind of what I want to achieve but I’m trying to get my head around how I can do it:

  • When the wall loads it will show the latest 20 wall posts
  • Every minute or so I will make an AJAX request to a feed which fetches any new comments - which weren’t loaded with the initial page load - if there are any.

The question is how do I filter the Data Source in the feed. My initial idea was to pass the date and time of the last wall post loaded using a URL param ($last-post-date), like this:

/path-to-feed/2009-07-22-23:14:35/

Then filter the Data Source using the param:

{$last-post-date} to {$today}

Which I hoped would be something like this:

2009-07-22 23:14:35 to {$today}

However as I found out, the date range filters don’t work using time http://getsymphony.com/community/discussions/77/2/#position-30

So what is my next option?

I was wondering if I could pass the system ID of the last wall post, then filter the DS so it only returns entries where the ID is greater than my param. But to my knowledge that’s no possible.

Any thoughts?

You could order entries by descending System ID order and take the first page. If you pass the latest known ID you can filter any old ones out in your XSLT to keep the AJAX payload light.

It’s a shame you cannot use less than or greater than on the System ID filter.

I can’t think of another way just now. I suppose actually this should be raised as a bug, that the Date field (which implicitly provides both dates and times) can be filtered by dates but not times.

I suppose actually this should be raised as a bug, that the Date field (which implicitly provides both dates and times) can be filtered by dates but not times.

Actually this inability always distracted me. Think of a simple example: An author wants an article to appear at 10:00 am. I will have to tell him that midnight is the right time.

@Nick: Would you please post this as a bug? I can’t, because Alistair is going to kill me if I post one more…

use

2009-07-22 23:14:35 to now

It supports PHP built in constants :)

@nickdunn the issue with that approach is that I will have to limit the DS, to say 50, and if more than 50 messages have been added some will never be shown.

I think I’ve got a solution.

  • Lets assume that the message wall updates once a minute
  • There are 1440 minutes in a day
  • So I’ll add a new field to the Wall Posts section called Minute Code
  • When a wall post is added, I’ll populate the Minute Code from within the event - based on the time. e.g if its added at 01:25 am the minute code will be 85
  • I’ll always know the Minute Code of the last post loaded, so for each feed request I can increment that by one, pass it through the URL param and filter the DS thusly.

That should work.

That would indeed work. If you’re happy customising your event to that extent, you could have a Number field (which supports native numeric sorting I believe) into which you could store the current timestamp (time()). Since this is an ever-increasing number you can compare to a known timestamp/date.

brendo: good spot. However although the __parseFilter function appears to take times into account, these are discarded for the SQL comparison:

"(DATE_FORMAT(`t$field_id".$this->key."`.value, '%Y-%m-%d') >= '".DateTimeObj::get('Y-m-d', strtotime($date['start']))."' AND DATE_FORMAT(`t$field_id".$this->key."`.value, '%Y-%m-%d') <= '".DateTimeObj::get('Y-m-d', strtotime($date['end']))."') "

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details