Im trying to clean up an old bit functionality in my template, because, well, its old and theres a few to many moving parts for my liking. It works, but it works the way described in the cookbook which I think is a bit of an old way now.
Basically the whole point is to generate a json file of all the pages in the site so I can feed it to Uncss so that it can optimise the CSS for unused code.
Right now, I have a page template, and content file, and a blue print that hides the page in the panel. if i go to domain.dev/uncss
i get the JSON in the browser. I use curl
to save the this to a file on the file system and then pump that into uncss… it works but to many moving parts.
how can i clean up, remove stuff, and have it so that on a local domain i can visit domain.dev/uncss.json
and feed that directly to uncss without have to save the file via curl and have the template and content files?
I read the load more from ajax guide, but thats just confused me further
My page template looks like this, because Uncss is expecting a particular format to the JSON…
<?php
header('Content-type: application/json; charset=utf-8');
$root = $site->find('home');
$firstlevel = $site->children()->visible();
$secondlevel = $site->children()->children()->visible();
$thirdlevel = $site->children()->children()->children()->visible();
$json = array();
$json[] = (string)$root->url();
foreach ($firstlevel as $article) {
$json[] = (string)$article->url();
}
foreach ($secondlevel as $article) {
$json[] = (string)$article->url();
}
foreach ($thirdlevel as $article) {
$json[] = (string)$article->url();
}
echo json_encode($json);
How do i convert this into the way described above?