Jump to content

Timestamp for FieldtypePage


Raymond Geerts
 Share

Recommended Posts

I'm not sure if this is the right place to put this or if this could be seen as a feature request. Maybe it is possible to solve it with a Process module instead.

It would be nice to be able to query the FieldtypePage and filter it on a timestamp.

/**
 * Return the database schema in predefined format
 *
 */
public function getDatabaseSchema(Field $field) {
    $schema = parent::getDatabaseSchema($field);
    $schema['data'] = 'int NOT NULL';    
    $schema['keys']['data'] = 'KEY data (data, pages_id, sort)';
    return $schema;
}

The extra column i'm thinking about would be named 'added' and would work the same as the 'modified' field used in pages for example.

$schema['added'] = 'timestamp NOT NULL default CURRENT_TIMESTAMP';

In this way every time you add a Page to a InputfieldPage the timestamp is automaticly set to the current date and time and saved to the database.

With this extra column it should be possible to get pages added to a InputfieldPage field on a certain date and time, or after/before a certain date and time.

For example if you have a friends, incomming friends, outgoing friends list with Users, with this extra field it will become possible to show new added friends (or incomming request) after last login.

It would be a small addition to the already available FieldtypePage, does'nt take much space in the database but gives some extra benefits for the usage.

I have tried to Make two custom modules for this, namely FieldtypePageTimestamp and InputfieldPageTimestamp but somehow it wouldnt display any variables (name,title,etc..) of the pages anymore. Could be because these are core and are completely interwoven, not sure.

I have thought about a custom process module but that would just bring a lot of overhead of data and processing with it. Atleast in the way i was thinking it should have 3 extra fields, for page id, linked page id and timestamp. So that might not be the way to go.

Link to comment
Share on other sites

Update, i noticed to get this working all it needs is an extra column to the FieldtypePage with the folowing settings.

Now i did it manualy to the database. To have it work automaticly for each FieldtypePage field that is added it needs to be added here.

$schema['modified'] = 'timestamp NOT NULL default CURRENT_TIMESTAMP';

Then it works and you can request the modified (added) date timestamp this way.

foreach($pages->find("template=templateWithInputfieldPage") as $somePage) {
echo date("d-m-Y H:i:s", $somePage->modified)."<br>";
}

This will spit out the date that page B was added to page A InputfieldPage field.

post-694-0-26715500-1396467875_thumb.png

post-694-0-51976600-1396467876_thumb.png

For me this would be a very useful feature for the FieldtypePage.

But i'm aware there is a good chance this addition is not that interesting to Ryan or others.

So i hope this will make it to the core, but if not does anybody know how to turn this in to a module? One that just adds the extra modified field to each FieldtypePage (InputfieldPage) automaticly?

  • Like 2
Link to comment
Share on other sites

After doing some more testing it seems that it does not work the way i thought it would work. :(

->modified would hold the value of the modified field of the page being added, and not the modified timestamp of when the page was added.

@martijn zz-top in disguise?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...