-
-
Notifications
You must be signed in to change notification settings - Fork 615
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JSON/AJAX response #324
Comments
Yes and no. 😉 You can't prevent Pico from parsing a page (doing so is planned for Pico 2.0, see #317; feedback is btw highly appreciated), but it makes no difference whether you discard the output of the Off Topic: Provided that you don't do anything else in your Your plugin could then look like the following, neither a class PicoAjax extends AbstractPicoPlugin
{
public function onPageRendered(&$output)
{
if ($this->getRequestUrl() === 'ajax') {
// query goes here, which returns JSON list
header($_SERVER['SERVER_PROTOCOL'] . ' 200 OK');
header('Content-Type: application/json');
$output = json_encode($query);
}
}
} |
Thanks for explanation. After doing bunch of CMS benchmarks regarding which to use for my new website (all of them required database connection), I was not satisfied with performance of Wordpress, which is overkill for shared hosting. After doing some browsing, I had recently discovered Pico and got very impressed with how fast it is, especially on shared hosting and planning to use it for news/blog/portal website, with custom plugin which would take care of basic things which most of blogs have, like categories and pagination. Flexibility is probably main issue with Pico, currently. Core seems very "hard-coded" and option to choose between native PHP templating and TWIG (or any other template engine) would be very welcome. Since Im planning to use Pico for my future websites which would have more-less similar structure, I would provide feedback on any problem or issue when I find some. Keep up the good work and just dont let whole project turn into monstrosity Wordpress has become. Pico just needs some issues to be resolved, while keeping things simple (and small) and It would be great. 😄 |
Thank you for your feedback! This summarises my plannings for Pico 2.0 pretty good, so please stay tuned 😃 |
How to perform AJAX with Pico, returning JSON response? Im guessing "onRequestUrl" should be used for this action and create page "ajax.md" in content directory, but Im not sure this is correct approach since without creating .md page, AJAX is not working/request URL is not found. Plugin structure for this action is here:
PicoAjax.php
ajax.md
ajax.twig
{{ ajax_response }}
Code above works, and returns correct JSON response used for infinite scrolling list BUT only when ajax.md is created, otherwise, it is 404. Is it possible to request URLs without creating "page" (markdown) file?
The text was updated successfully, but these errors were encountered: