Skip to content
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

Add documentation on using debugger with admin plugin #60

Open
hamiltont opened this issue Jan 30, 2019 · 0 comments
Open

Add documentation on using debugger with admin plugin #60

hamiltont opened this issue Jan 30, 2019 · 0 comments

Comments

@hamiltont
Copy link

This took forever to figure out, so I'm hoping this issue can be a launching point for writing some documentation on a painful edge case I ran into when trying to build & debug a new shortcode extension. The TLDR is a docs that says something like this "for code running inside shortcode handler functions, to output debug information you should either return the log information as part of the shortcode handler return value, or you should use the grav log. Usage of the grav debugger will work in most situations, but log information will not be displayed inside the admin plugin"

Here's why (The following issue assumes all caching is turned off, so every request should re-trigger processing....)

When using the editor (at /admin/pages/<page route>) you are by default in the "Editor" mode. When you switch into the "Preview" mode, you can see the end result of your custom shortcode handler logic. However, if you have Grav debugger statements inside your shortcode handler function, they will not be displayed in the page's debugger log

The problem is that clicking "Preview" triggers a "processMarkdown" AJAX call to awaken grav and handle processing the markdown and by extension calling shortcode-core which will call your custom shortcode handler logic. Processed content will be returned via the same AJAX call via the magic of the admin plugin, but the debugger log contents are not returned.

On a different note, I went down this rabbit hole of debugging because my shortcodes work fine on /admin/preview/... but do not work on /admin/pages/.... It currently seems some high level information is different between those two, e.g. the $page variable changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants