I'm importing blog posts from 0.9 but even though I set the time_created on the post in 1.5, it doesn't seem to have any effect. Is it possible to set time_created on an ElggObject? The posts all have the date/time they were imported:
$blog = new ElggObject();
$blog->subtype = "blog";
$blog->time_created = $time;
$blog->time_updated = $time;
$blog->save()
info@elgg.org
Security issues should be reported to security@elgg.org!
©2014 the Elgg Foundation
Elgg is a registered trademark of Thematic Networks.
Cover image by Raül Utrera is used under Creative Commons license.
Icons by Flaticon and FontAwesome.
Take a look at create_entity() - it sets the time_created and time_updated time in there. Did you try:
$blog = new ElggObject();
$blog->subtype = "blog";
$blog->save();
$blog->time_created = $time;
$blog->save();
Didn't think to save it twice. So tried it as you suggest but it still doesn't have any effect:
$blog->save();
$blog->time_created = $time;
$blog->time_updated = $time;
if ($tags != "") {
$blog->tags = string_to_tag_array($tags);
}
$blog->comments_on = "On";
$blog->save();
time_updated has no effect either as it says "never" when you view the post
time_created is set by the system time when the object is created and is not saved along with the other metadata, so it doesn't seem to be possible to change that time.
I'm don't understand why time_updated is not being set because the save method should set it to the current time.
Another suggestion:
$blog->setMetaData('time_created', $time);
that doesn't work either! I've just remembered I'm using 1.5 RC2 for this. Best I upgrade to 1.5!
Sorry - I was forgetting that time_created is not normal metadata but is part of the entity table. That leaves two possibilities:
1. use the import method
2. write a small extension to the entity class that allows you to set the time_created
@Brane
what value do you want $blog->time_xxx to be ?
the blog time should be the time it was posted in Elgg 0.9 (that's in the ODD file). I want the migration to be as close as possible to just a "theme change". i.e. almost all the original data will appear with correct dates etc.
@Cash, thanks for the pointers. I'll upgrade to 1.5 and poke around further
@Brane
( luv that name ;-O)
retaining orig blog date from v0.9 can be done
mssg me to my inbox and we'll take it from there.
For do this you need to make a SQL call. The code for make it is available in the migration tool that I uploaded just some minutes ago.
- Previous
- 1
- 2
- Next
You must log in to post replies.