Skip to content

Instantly share code, notes, and snippets.

@isaactopo
Last active August 29, 2015 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save isaactopo/9705e7a57a8dcddaa32a to your computer and use it in GitHub Desktop.
Save isaactopo/9705e7a57a8dcddaa32a to your computer and use it in GitHub Desktop.
Read and Write a Kirby text File Data.
<?php
// Read the Kirby Data from the page Text File 'kd'
$doc = data::read($page->textfile(), 'kd');
// Add or modify the entries
$doc['Text'] = 'Lorem ipsum dolor…';
$doc['Likes'] = 22;
// Write the Text File with the new data
if(data::write($page->textfile(), $doc, 'kd')) {
echo 'Done';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment