Skip to content

Instantly share code, notes, and snippets.

@bastianallgeier
Created July 12, 2012 08:35
Show Gist options
  • Save bastianallgeier/3096734 to your computer and use it in GitHub Desktop.
Save bastianallgeier/3096734 to your computer and use it in GitHub Desktop.
<?php
if(!r::is_ajax()) notFound();
header('Content-type: application/json; charset=utf-8');
$data = $pages->find('blog')->children()->visible()->paginate(10);
$json = array();
$json['data'] = array();
$json['pages'] = $data->pagination()->countPages();
$json['page'] = $data->pagination()->page();
foreach($data as $article) {
$images = array();
foreach($article->images() as $image) {
$images[] = array(
'url' => $image->url(),
'width' => $image->width(),
'height' => $image->height()
);
}
$json['data'][] = array(
'url' => (string)$article->url(),
'title' => (string)$article->title(),
'text' => (string)$article->text(),
'date' => (string)$article->date(),
'images' => $images,
);
}
echo json_encode($json);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment