kolewu Posted September 28, 2012 Share Posted September 28, 2012 Hello, I'm new into ProcessWire and I love it! Originally I have planned to evaluate several CMS and then decide which one to use -- but after some hours with PW I decided not to look any further But now I'm stuck with the guestbook from the old site and beg for help: How can I import the old postings with the correct date into comments? Since they have their own database table and are not organized as (sub)pages, I cannot use the import module, right? And because the old guestbook has had an optional website field: how can I preserve this? I know that the comments should be enhanced with this type of field sometimes (+1 from me for this feature!) ... Thank you Uwe Link to comment Share on other sites More sharing options...
Mats Posted September 29, 2012 Share Posted September 29, 2012 Hello! If you can get the comments out of our old CMS in json or XML you could use this method: Also check this for creating pages with the API: Good luck and welcome! Link to comment Share on other sites More sharing options...
kolewu Posted September 29, 2012 Author Share Posted September 29, 2012 Thank you Mats! I wonder how I have not found this ... maybe I have only searched the site and not the forums. Will try to use the infos as soon as possible -- unfortunately the old guestbook is not from a CMS but an hardwired cgi-script and I have to convert the HTML table, but this is not a PW problem Link to comment Share on other sites More sharing options...
kolewu Posted October 6, 2012 Author Share Posted October 6, 2012 OK, here I am again. The import has been successfully carried out with the help of the links above but after solving some problems ... The first step was to convert the old guestbook to json and after it was converted to CSV this web app http://www.cparker15...es/csv-to-json/ Then I spent some time to work around the scripting problems but with this template, the json file was successfully converted to comments. <?php # moderation of comments must be disabled before running this script # likewise the email sending for a comment should be switched off $file = './guestbook.json'; $data = json_decode(file_get_contents($file), true); if(!$data || $data == false) throw new WireException("Can't load data from $file."); $p = $wire->pages->get("/gaestebuch/"); $p->setOutputFormatting(false); foreach (array_reverse($data) as $item) { $c = new Comment(); $c->text = trim($item['text']); $c->cite = trim($item['name']); $c->email = trim($item['email']); $c->homepage = trim($item['website']); $c->created = strtotime(trim($item['date'])); # setting status has no effect if moderation is set to "only new" $c->status = 1; $p->comments->add($c); } $p->save('comments'); $p->setOutputFormatting(true); echo 'import successful'; The following problems had to be solved json_decode() only returns an array with the data and not with any metadata, so the result is the return value and not in $data['status']. Output formatting has to be disabled around the save. If moderation for the comments is set to always or only new, setting status doesn't has any effect -- so the moderation mode must be set to none before the import. If email notification for comments is enabled, every new comment triggers an email -- so it would be wise to disable email notification before import. Now I only miss a field for a website and since it is part of the roadmap for the next PW version I would like to know if there is a (preliminiary) implementation that I can use to import this field in a compatible manner. May this be helpful to anyone. 1 Link to comment Share on other sites More sharing options...
ryan Posted October 7, 2012 Share Posted October 7, 2012 Now I only miss a field for a website and since it is part of the roadmap for the next PW version I would like to know if there is a (preliminiary) implementation that I can use to import this field in a compatible manner. Thanks for posting this. The website field isn't in there yet, but it planned for 2.3, so I will try to go ahead and get this into the dev branch here shortly. Link to comment Share on other sites More sharing options...
er314 Posted October 15, 2012 Share Posted October 15, 2012 While we are at the comments API, I was considering implementing a "search" feature on comments, but it seems that find() API can't be used for this : Error Exception: Operator '*=' is not implemented in FieldtypeComments Error Exception: Operator '~=' is not implemented in FieldtypeComments Do you have plans to implement these operators ? thanks Link to comment Share on other sites More sharing options...
ryan Posted October 15, 2012 Share Posted October 15, 2012 Interesting, I didn't realize we didn't have those implemented for FieldtypeComments, but you are right. We've already got the fulltext index there to do it, so definitely need to add this support. I have added it and will test locally before pushing to the dev branch. 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now