Created
July 12, 2012 08:35
-
-
Save bastianallgeier/3096734 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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